Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

navigate to anchors within the current page

Status
Not open for further replies.

JerryH

Programmer
Jul 8, 2000
15
0
0
US
The following is a script I found at irt.org:

<script language=&quot;JavaScript&quot;><!--
function go() {
location.href = '#' + document.myform.mylist.options[document.myform.mylist.selectedIndex].value;
}
//--></script>

<form name=&quot;myform&quot;>
<select name=&quot;mylist&quot;>
<option value=&quot;flyfishing&quot;>Flyfishing
<option value=&quot;flytying&quot;>Fly Tying
<option value=&quot;saltwater&quot;>Saltwater
</select>
<input type=&quot;button&quot; value=&quot;Submit Query&quot; onClick=&quot;go()&quot;>
</form>

It works great in IE, but can it be fixed to run in Netscape?
 
try to use document.location.href instead of location.href.

Netscape has window as a default root element. IE has a document. So, you need to use 'document' prefix if you want to have cross-browser code.

Regards,
Sergey Smirnov
Ask me directly at:
 
What does it do wrong in your page?

It works fine for me in N4.7 and N7.0.
 
Thanks for all the responses, I have it working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top