View Full Version : Run script AFTER page refresh?

01-05-2011, 01:39 AM
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

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?

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.

01-05-2011, 01:49 AM
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