SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict Pavel_Nedved's Avatar
    Join Date
    Aug 2004
    Location
    Victoria, BC
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Disabling The Refresh Button

    Hi,

    I want to stop people from refreshing on a certain page. How do I disable the "refresh" button & "view > refresh" using javascript.

    Thanks very much.

    Pavel

  2. #2
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i dont think you can. especially since browsers have refresh on top anyway...

    plus if there was a way of prevent reloading of a page, it would probably need to be done with server-side script.

    why do you want to disable it?
    James Rice :: Ex-Mentor
    www.jamesrice.net

  3. #3
    SitePoint Addict Pavel_Nedved's Avatar
    Join Date
    Aug 2004
    Location
    Victoria, BC
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll just describe the page for you.

    It's a php page that first runs a mail script, then depending whether or not the email gets sent, a success page shows up to confirm it using the include() function.

    I suppose if you can't disable "refresh", then what I'll have to do instead is change the confirmation page from an include to a redirect. Having said that, if the person was then to hit "back", I'd probably run into the same problem.

    Having said THAT, I know that in PHP, we can detect what page was previously viewed, and if it is the success page, I can stop the script from executing.

    Now, that's a lot of work, so here's my new question. Can I detect if the page has been refreshed using PHP? If so, I can insert just one or two lines of code, rather than about 50 (the confirmation page is a bit complicated).

  4. #4
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i woulod just have one page do the actual mail(), and then pass the user to a different confirmation page using header("location:..."). then pressing refresh would not matter.
    James Rice :: Ex-Mentor
    www.jamesrice.net

  5. #5
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    JavaScript cannot control the browser that way. James' suggestion is your best bet. Just redirect them away from the page to prevent them from refreshing it again.

  6. #6
    SitePoint Addict Pavel_Nedved's Avatar
    Join Date
    Aug 2004
    Location
    Victoria, BC
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers for your help guys. I hope you have a wonderful Christmas.


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
  •