...

View Full Version : Anchor not working correctly with NS7



florida
12-28-2005, 04:02 PM
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?

<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:


<body>
<p>Info line one </p>
<p id="foo">Info part for anchor to go to. </p>
</body>

Kor
12-28-2005, 04:07 PM
try
<p name="foo">

florida
12-28-2005, 06:07 PM
Thanks,

I tried that and it didnt work.

Any other suggestions?

Kor
12-29-2005, 08:19 AM
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">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum