...

View Full Version : Run script AFTER page refresh?



Johnb21
01-05-2011, 02: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?

**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.

Nile
01-05-2011, 02: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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum