Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-28-2005, 04:02 PM   PM User | #1
florida
Regular Coder

 
Join Date: Jul 2002
Posts: 362
Thanks: 0
Thanked 0 Times in 0 Posts
florida is an unknown quantity at this point
Anchor not working correctly with NS7

The below takes me from a selection option on one page to another page (thePage.cfm where it puts me in a specific part of the page using an anchor).
It works great in IE but Netscape 7 doesnt go to the anchor part of thePage.cfm. It seems to only partially take me to the correct part of the page where it seems to go to high and only partially show the correct section. Please advise how I can correct it with NS7?
Code:
<script>
function goToOtherPage()
{
   document.location.href=document.formName.myField[document.formName.myField.selectedIndex].value;
}
</script>
<form>
<select name = "myField" onchange="return goToOtherPage()">
<option value="thePage.cfm#foo"></option>
</form>
thePage.cfm:
Code:
<body>
  <p>Info line one </p>
  <p id="foo">Info part for anchor to go to. </p>
</body>
florida is offline   Reply With Quote
Old 12-28-2005, 04:07 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
try
<p name="foo">
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 12-28-2005, 06:07 PM   PM User | #3
florida
Regular Coder

 
Join Date: Jul 2002
Posts: 362
Thanks: 0
Thanked 0 Times in 0 Posts
florida is an unknown quantity at this point
Thanks,

I tried that and it didnt work.

Any other suggestions?
florida is offline   Reply With Quote
Old 12-29-2005, 08:19 AM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
1. location is the window's attribute, not the document's
2. It is enough to use select's value, as it is always the same with the selected option's value

window.location.href=document.formName.myField.value;

You may also shorten the code like this:

<select name = "myField" onchange="location.href=this.value">
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 12-29-2005 at 08:21 AM..
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:27 PM.


Advertisement
Log in to turn off these ads.