SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    referrer redirect before body loading?

    I'm about to impliment the following referrer redirect on my site:

    var who = document.referrer;

    if (who.indexOf('http://www.mydomain.com/preloader.html') != -1) {
    doNothing() }
    else if (who.indexOf('http://www.mydomain.com/thankyou.html') != -1) {
    doNothing() }
    else {
    window.location="http://www.mydomain.com"
    }


    This redirects the user to my index page unless they arrive via either my preloader page (immediately before my main page) or my contact form return page.
    These are the only two pages in my site that link to the main page.

    I used this as I was having trouble getting the syntax right (beginner) when using the || comparison.

    I'm happy to use this for now as I know it works.

    However, when I go to the main page from neither of these two (to test the redirection) the main page begins to load some of the body elements before the redirection script kicks in.
    It starts laying out divs and their images (though only the placeholders are visible as none of the actual image data has started to arrive).

    This makes the page look like a complete mess.
    It is only for 2 or 3 seconds, but it still looks bad.

    I want to find a way that the referrer sniffer happens before any visual data is rendered.

    I have tried putting the script straight after the opening <head> tag and even before it, but I still get the beginnings of the visual data rendering.

    How do I ensure that this doesn't happen?

    Sorry if this seems confusing and garbled.

    TIA

    p.s.
    Is there a more 'technically correct' alternative to 'doNothing()'?
    There is no functional code for doNothing(), it is just an ad-hoc, dummy function.
    All I need is something that can be used as a command, but that actually does nothing but let the script continue on (and the page load)
    Last edited by Bill Posters; May 6, 2002 at 05:05.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bill,

    The problem you are having is with the caching of those items. They have already been loaded so they load much faster when redirected. Play with your cache settings.

    You do have a couple of options. One create a layer that hides the entire page until the page is done loading. Two, turn the caching off.

    As for the last question. Have you tried using void();
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just use

    PHP Code:
    <div style="display:none" onload="defaultStatus='redirecting...'">
      <!-- 
    your content -->
    </
    div
    how are you preloading your images?

    just make them preload in an array, thats all that should be needed for a simple preloader

  4. #4
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using a 3rd party preloader that has a graphic progress bar and auto forwarding.
    I posted it previously here where Andrew actually tweaked/fixed it for me to work with the earlier version of the referrer script.

    The referrer script has now been dumbed down a bit and is currently:

    var from = document.referrer;
    if (from == "http://www.mydomain.com/preloader.html") {
    void();
    }
    else if (from == "http://www.mydomain.com/thankyou.html") {
    void();
    }
    else {
    window.location = "http://www.mydomain.com";
    }


    Various teething troubles/conflicts lead me to this particular solution and it now works a treat.

    The problem with the loading of the images is not to do with the cache.
    I have flushed the cache and even trashed the cache (IE) and yet there is still some loading of the page before the referrer check kicks in.

    This creates problem aside from the 'messy' appearance.
    One or two images mentioned early in the html are being particially rendered before the referrer kicks in.
    When the main page is loaded as planned and those images are rendered on the page, only the portion of the image that was loaded the first time round is being loaded.
    This is because when the image was being loaded first time round, the transfer of data is being interupted by the referrer script.
    This kinda foobahs the cached copy of that image (which is 'found' and 'used' by the cache when the page is visited correctly)

    Thx for the thought Maelstrom, but playing with the cache settings was never going to been an option either way as I cannot alter the cache settings of every visitor who may come to my main page driectly from an SE link.

    ...unless you mean there is some way to affect the caching of the page from within the referrer script.
    (if... no cache) kinda thing.

    If you can understand what the hell I'm on about, I'd appreciate your input.

    Thx guys
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bill what the hell are you on about

    I dont understand how an img can appear on a page without the <img /> tag? That doesn't seem quite right, but if you use

    <meta http-equiv="pragma" content="no-cache">

    with this your images will not preload as get saved into the cache to speed up retreival of pages, which would defeat the purpose of a preload script, bill post the url, have a coffee and maybe explain little more hehe.

  6. #6
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My previous post was just the referrer script that goes in my main page header, straight after the opening <head> tag.

    Quite simply the page is beginning to load (i.e. reaching the <body> code before the referrer script reacts and does its thing.)

    Here is a link directly to the main page.
    You should be redirected straight away to the 'start' of that site, but you will see that the page begins to load before the script kicks in.

    Yes, I know that the pop-up window is too small on PC/IE5, but that's the stupid fault of PC/IE5.
    I will stick some kind of sniffer/resizeBy soon*, but supporting PCs isn't actually a priority.
    (*unless I can find a reliable centered pop-up script that gives reliable sizes x-browser/platform)

    Anyway, take a look and you'll (hopefully) see what I mean.

    And thx again.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


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
  •