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 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    63
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Run script AFTER page refresh?

    Is this possible? I am writing a script that will display an alert box that reads "your play was saved" after a user clicks the submit button on a form. The only problem is that after clicking save, the page refreshes. Here is the code I tried to use


    Code:
    function savedMessage(){ 
    document.getElementById("CmdFinish").addEventListener("click",function(e) {
      GM_setValue("Saved", 1); }, false);
      
      if (GM_getValue("saved", 0) == 1) {
      alert("Your play has been saved");
      GM_setValue("saved", 0); // or GM_deleteValue("saved"); }
    }
    The button ID is "CmdFinish" and the value is "saved". Is there ANY way i can make the script run only on a page refresh?

    **Note**
    The script is for a specific page and not the whole site, so it wont run on every refresh on the site, only when it's needed on 1 page.

  • #2
    Regular Coder Nile's Avatar
    Join Date
    Jun 2008
    Posts
    280
    Thanks
    2
    Thanked 46 Times in 46 Posts
    You could try setting a cookie or when saving the page, you could add something like ?saved=true, and splice it using splice and indexOf


  •  

    Posting Permissions

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