How to detect someone stopping the page load before everythings loaded?

Discussion in 'Programming' started by yogesh1099, Nov 29, 2008.

  1. #1
    Hello,

    I 'spose the title says it all, I want to know whether the user has stopped the page from loading before it has completely loaded and perform action in that manner. I 'spose it can be done via javascript using "onunload" but I'm not sure if it detects page load cancelling through browsers...

    Thanks in advance...

    Regards
     
    yogesh1099, Nov 29, 2008 IP
  2. gordonrp

    gordonrp Peon

    Messages:
    76
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could place a bit of javascript at the end of the page, which would load once everything else has loaded. This javascript could hit a callback url of some sort.

    E.g. top of page, callback.php?id=23232

    bottom of page callback.php?id=23232&finished=1
     
    gordonrp, Nov 30, 2008 IP
  3. amine

    amine Active Member

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #3
    You do it by javascript event onload in body tag
     
    amine, Dec 1, 2008 IP
  4. yogesh1099

    yogesh1099 Active Member

    Messages:
    459
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    1
    #4
    well i know that part but it works even when the page has not been completely loaded and the page load is cancelled.
     
    yogesh1099, Dec 1, 2008 IP
  5. happpy

    happpy Well-Known Member

    Messages:
    926
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    120
    #5
    put in a timeout that triggers a load of a callback-URL after some given time, which you are sure the whole page has loaded.
     
    happpy, Dec 5, 2008 IP
  6. yogesh1099

    yogesh1099 Active Member

    Messages:
    459
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    1
    #6
    thanks, i think i'll use both, the callback url and onload. that should make it better. thanks for all your suggestions :)
     
    yogesh1099, Dec 5, 2008 IP
  7. pitreq

    pitreq Peon

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    yes both way are the best
     
    pitreq, Dec 5, 2008 IP
  8. yawez.com

    yawez.com Peon

    Messages:
    187
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I would recommend using callback method. It is efficient.
     
    yawez.com, Dec 6, 2008 IP