Click to See Complete Forum and Search --> : GoTo Address Bar


matthewhse
04-21-2003, 10:47 AM
Hi,

I've been looking for a simple script that will allow me to put a "GoTo" bar on my webpages. It would just be a textbox with a "Go" button that would take the visitor to whatever webpage they typed in the textbox.

I would write this myself, but don't know enough scripting to do it. I was hoping someone could direct me to a script that would do this.

The "GoTo Bar" should ideally open pages in a new browser, and work regardless of whether or not the user types "http://" or "www."

Any help would be greatly appreciated. Thanks in advance,

Matthew

AdamGundry
04-21-2003, 11:38 AM
Try something like this (untested):

<input type="text" id="gotobar"> <input type="button" value="Go" onclick="nav()">

<script type="text/javascript">
function nav(){
window.open(document.getElementById('gotobar').value);
}
</script>

You may want to add protocol checking before the window.open(), so the user does not have to type "http:". I wouldn't check for "www." however, because if the user wants to get to a different subdomain they cannot.

Adam

matthewhse
04-21-2003, 11:55 AM
Thanks Adam, this works as-is as long as the http:// is included. I'd never heard of protocol checking before, though. Ran a Google search to try to find some more information about how to do protocol checking but don't have time just now to sift through the results. Thanks for the help -- it looks like this will do just what I want it to do, with just a little tweaking!

Matthew

AdamGundry
04-21-2003, 11:59 AM
"Protocol checking" is not a technical term, its just what I thought testing to see if there is a valid protocol on the start of the address (e.g. http:, ftp:, etc.) could be called.

Good luck with the tweaking.

Adam

Jona
04-21-2003, 07:53 PM
Try this:

http://geocities.com/god_loves_07/go_bar.html