SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: body onload

  1. #1
    SitePoint Addict
    Join Date
    Dec 2003
    Location
    USA
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    body onload

    I have created a page that takes a person to another page automatically:

    <body onLoad="location.replace('whatever.html')">

    However, the script waits for the entire page to load before actually taking the person to the other page. What I need to do is to have a script that takes the visitor to the target page as soon as the page appears (without waiting for ads to load completely). How can this be done?

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Don't even wait that long to use your code. At the very top of the page use this:

    <script>
    location.replace('whatever.html');
    </script>

    You may want to use a meta refresh tag as well for non javascript browsers:

    <META HTTP-EQUIV="refresh" CONTENT="0; URL=whatever.html">

  3. #3
    SitePoint Member boldlygoing's Avatar
    Join Date
    Jun 2004
    Location
    World Citizen
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick Question on the META option??

    Quote Originally Posted by stymiee
    You may want to use a meta refresh tag as well for non javascript browsers:

    <META HTTP-EQUIV="refresh" CONTENT="0; URL=whatever.html">
    Is there any particular order that these two should be in?
    Code:
    <script>......</script>
    <META HTTP_EQUIV="refresh"...>
    
    or
    
    <META HTTP_EQUIV="refresh"...>
    <script>......</script>
    The reason I ask is that if it does make a difference, and I want to pass some variables through the <script> function, I'd be hard pressed to know why it doesn't work if I have the above tags in the wrong order

  4. #4
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unless the variables are being passed as part of the URL to a server-side script, or being written to a cookie, I'm not sure I see how you will pass them between pages, anyway.

    The browser should operate on the tags and their contents as it encounters them, so if you want the script to take precedence, place it before the meta tag.


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
  •