I tried changing so much, but I got stuck. It works when I comment out window.location and leave just alert. It alerts me fine with correct url. It just does not want to open that url! You can see the actual attempt here: http://ronimarinkovic.com/dina/location.html Code I'm using is: function convertURL() { var url = document.getElementById('start').value; if (url=='') { alert('Enter Starting point.'); return false; } var final_url; final_url = 'http://maps.google.com/maps?saddr='+ url +'&daddr=43.26292335379714,16.65346437622564'; //window.location = final_url; //alert(final_url); window.location.replace( final_url ); } Code (markup): <form name="SearchForm" action="" onsubmit="return convertURL(this);"> <label id="label1">Get directions from (city, country) </label> <input id="start" name="text1" type="text" /> to Bol apartments Dina <input id="directions" name="Button1" type="submit" value="Get Directions" /> </form> Code (markup):
tried... and tried again and again... window.location window.location.href window.location.open window.location.replace Confusing is that when I leave alert, it alerts me with proper ly created url, and when I want to open that url it just adds ?text1=Padova%2CItaly&Button1=Get+Directions arguments to parent url!?!?!
Ahh, your form is submitted. Try this: function convertURL() { var url = document.getElementById('start').value; if (url=='') { alert('Enter Starting point.'); return false; } var final_url; final_url = 'http://maps.google.com/maps?saddr='+ url +'&daddr=43.26292335379714,16.65346437622564'; //window.location = final_url; //alert(final_url); window.location.href= final_url ; return false; } Code (markup): I didn't test this code, but something like this should work.