View Full Version : "custom location bar"

01-27-2009, 05:08 PM
I'm trying to get a variation of the CUSTOM LOCATION BAR on http://www.sivamdesign.com/scripts/navigate.html (code can be found at http://www.sivamdesign.com/scripts/dwld/location.txt )to work.

Basically, I want to have users enter a string (e.g., 1234) into a text box, click on the GO button, and then be taken to

Is that possible, and if so, how is it done?

Any help is greatly appreciated!

01-28-2009, 04:02 AM
Here you go:

<script type="text/javascript">
var locateTo = function(els){
window.location.href = "page.php?"+els.elements['locate'].value;
<form action="page.php" method="get" onsubmit="locateTo(this); return false; ">
<input type="text" name="locate"/><input type="submit" />

You should also make this compatible with javascript disabled users. To do this, on page.php, add:

if(isset($_GET['locate'])) {
header("Location: ".$_SERVER['PHP_SELF']."?".$_GET['locate']);

Of course - if you do that then all you need to do with the <form> I gave you 2 codes above is:

<form action="page.php" method="get">
<input type="text" name="locate"/><input type="submit" />

Which I highly suggest.