SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to capture refresh of page

    i am using session cookies to store some values
    but i want the cookie to clear the data when the user refreshes the page
    how can i capture the refresh using javascript and call my function that clears the cookie

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try using the load event for the window object.
    Code:
    window.onload = function(){
    // your code
    };

  3. #3
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i cannot use onload event as the value of cookie will be reset after the page has fully loaded after refresh
    and i need the value of cookie to reset after the user clicks refresh as im changing the value of cookie as the page is loading
    and the value of cookie is not null when page is loading
    it sets to null only after page has loaded in onload

    i used another event onbeforeunload and it worked for me

    but onbeforeunload is not resetting the cookie in opera
    it is working fine in IE, firefox and netscape

    is there a way to implement in opera

    thanks in advance


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
  •