SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast Bad Dobby's Avatar
    Join Date
    Sep 2003
    Location
    North America
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    script for <body onLoad> works in IE but not Mozilla

    I am using a javascript to redirect my page upon the <body onLoad> funtion. It works great in IE, but does not do anything in Mozilla .... and clues? ... here is the code:

    Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_goToURL() { //v3.0
      var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    }
    //-->
    </script>
    
    <body leftmargin="5" topmargin="5" marginwidth="5" marginheight="5" onLoad="MM_goToURL('parent','#totop');return document.MM_returnValue">
    So when the page loads it repositions to the anchor named #totop. Works in IE but not Mozilla .... is there a simple snippet to add to get it to work in Mozilla too?

    Thanks
    I'm just a House Elf.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Try this function instead:
    Code:
    function goToSection(sectionName) 
    {
      location.hash = sectionName;
    }
    Then add it to your <body> tag like so:
    HTML Code:
    <body onload="goToHash('totop');">
    Last edited by vgarcia; Mar 14, 2004 at 07:45.

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The hash (#) signifies 'named anchor' - it isn't actually considered part of the anchor's name.

    <a name="totop">.....</a>

    MSIE doesn't care one way or the other...

    http://www.porjes.com/idocs/linking/_A_NAME.html
    ::: certified wild guess :::

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Oops, edited my post .


Bookmarks

Posting Permissions

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