www.webdeveloper.com
Results 1 to 3 of 3

Thread: JS to open link + jump to page #anchor

  1. #1
    Join Date
    Mar 2004
    Posts
    7

    JS to open link + jump to page #anchor

    I am doing an IDX portal (idx=real estate home search page).

    I am using a few different platforms that communicate with iframes, its a little murky, but its stable.

    When I click a link on my parent page, I want it to jump to a page anchor just above the iframe as it loads the href content. I'm not the best at JS, but here is my solution, and its not working. Help?

    my function-
    Code:
    <script type="text/javascript">
    function headAnchor()
    {
    window.location.hash="head"; 
    }
    </script>
    page anchor-
    Code:
    <a name="#head">
    link-
    Code:
    <a href="http://my.dom/mylink.php" target="iframe" onclick="headAnchor()">

    What am i missing?

  2. #2
    Join Date
    Mar 2004
    Posts
    7
    Oh, it works in IE (but only with compatibility view turned on). but not firefox or chrome. Whats the FF/C fix?

  3. #3
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    <a name="head"></a> w/o '#' ----> this is the point where the page will be scrolled to

    <a href="#head">head</a> -----> this is clicked to scroll the page to the anchor described above

    in XHTML or HTML5 use id attribute instead of name

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles