Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,149
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    <body onload = "clearCookie()" >

    function clearCookie() {
    .... clear the cookie
    }

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,149
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    The onbeforeunload event is a Microsoft proprietary invention, and neither Opera nor Safari implements it. Although Opera probably supports more of Microsoft's proprietary features than any other browser.

    BTW, the time to say "thanks" is afterwards, not before when "please" is usually considered polite. If you are find this response helpful then please use the "Thank You For This Post" button.


  •  

    Posting Permissions

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