CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2006
    Posts
    25

    Reload page in javascript

    hi


    when the browser refresh the page alert("msg") will be show using javascript .

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Reload page in javascript

    Page reload is not directly detectable. Your only option would be to create a cookie with the URL as the value and check for that cookie with the onload event. Then, if the cookie value is equal to the current URL, then the page has either been reloaded, or entered twice.

    You should easily be able to figure the code out.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Dec 2007
    Posts
    5

    Re: Reload page in javascript

    use
    <body onload="alert(msg);">

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: Reload page in javascript

    Quote Originally Posted by Snowcore
    use...<body onload="alert(msg);">
    The original poster only wants it when the page is reloaded, not loaded every time.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    May 2004
    Location
    MN / NJ, United States
    Posts
    768

    Re: Reload page in javascript

    Using PeejAvery's approach, setting the cookie in the onunload event with an expiration of, say 5 seconds would allow detecting the cookie onload. If the cookie is found, throw the alert message.

    I recognize the thread is a tad old, but if the original poster wants this type of solution, I suppose he'll be asking how to code it as well. That's where you come in Paul.
    *9-11-01* Never Forget; Never Forgive; Never Relent!
    "If we ever forget that we're one nation under God, then we will be a nation gone under." - Ronald Reagan

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured