Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try
    <p name="foo">
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks,

    I tried that and it didnt work.

    Any other suggestions?

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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">
    Last edited by Kor; 12-29-2005 at 09:21 AM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •