| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Ask Users to Confirm Before Leaving a Page with Post Data; Prevents the loss of posts due to careless link clicking or accidental refreshes. | |
|---|---|
| Tweet Topic Started: Jun 16 2012, 07:42 PM (2,782 Views) | |
| Makaze | Jun 16 2012, 07:42 PM Post #1 |
|
Discordian
![]() ![]() ![]()
|
Code Name: Ask Users to Confirm Before Leaving a Page with Post Data What the code does: When a user tries to leave a page or reload the same page, this script will check to see if they have entered post data. If they have, it gives them a prompt warning them that they have unsaved data and asks them if they really want to leave. Currently applies to:
The script is passive. No user input is required. How to install the code: Enter the following code under Admin CP » Board Template » Below the Board:
Extra notes: My spacing is entirely for readability, and an experienced editor may remove empty spaces and newlines to save space if necessary. Credits are also unnecessary, but if you could leave it, I would appreciate it. Edited by Makaze, Jun 16 2012, 07:53 PM.
|
![]() |
|
| Geoffrey | Jun 16 2012, 07:49 PM Post #2 |
|
bury hatchets, keep maps
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Ah nice, this is a pretty useful code.
|
![]() |
|
| SandyC (PM) | Jun 16 2012, 08:56 PM Post #3 |
![]()
Member
![]() ![]() ![]() ![]() ![]() ![]()
|
Good idea, I need something like this, lol... |
![]() |
|
| Dannyy | Jun 17 2012, 08:37 PM Post #4 |
|
Member
![]() ![]() ![]() ![]()
|
Wow, every single forum needs something like this. I've lost my data on numerous occasions when I've typed directly into my homework submissions at school as well. This code is so useful. Thank you!! |
![]() |
|
| NielsGuchelaar | Jun 18 2012, 06:47 AM Post #5 |
|
Member
![]() ![]() ![]()
|
Amazing code ! Thank you
|
![]() |
|
| 2wise69 | Jun 18 2012, 01:51 PM Post #6 |
![]()
Member
![]() ![]() ![]() ![]()
|
Nice. Thank you for this. |
![]() |
|
| Dream Endlessly | Oct 7 2012, 07:22 PM Post #7 |
|
Member
![]() ![]() ![]()
|
Appreciate it. Using! |
![]() |
|
| ringthebellamy | Nov 14 2012, 09:43 PM Post #8 |
![]()
Dum Spiro Spero
![]() ![]() ![]()
|
I have experienced problem with this javascript. Only two times so far in my whole experience, but it needs me to restart my iMac in hard way (turn it off by turn off the electricity). I'd appreciate it if someone can tell me whether there's something wrong with the script, the browser, or the computer. So I just casually type something on the board, then I accidentally swiped my mouse so it goes to last or next page. Obviously, the script would ask me and give me option to "stay on page" or "leave page", right? In most times, I can click one of those two options and everything is fine. But sometimes, it seems to be broken in a way that I clicked on "stay on page" or "leave page" and nothing happens. It's just there, keep asking me the same question again and again. And I haven't find any way to stop it from doing this except take off the electricity from the computer; it doesn't want to close Mozilla Firefox, the browser I use. Which means, my iMac won't restart the normal way (the usual way, you command it via Apple Logo > Restart...) because the Firefox is still on and needs to be closed before restarting. But I really like this script and it has been working nice big time, only sometimes, when it breaks... let's say it breaks hard. I'm taking this script off from my board for a while until I can understand this weird behavior of the script (or its relation with my browser and or my computer). |
![]() |
|
| Twinkle And Kessie | Aug 28 2013, 04:08 AM Post #9 |
![]()
Also Known As Carol And Nella
![]() ![]() ![]() ![]()
|
I hope the incident that happened to ringthebellamy has been resolved since this code was posted, I really need this code for my own board but I don't want issues like these happening to my members. /-: |
![]() |
|
| JadedOne-ZNS | Aug 31 2013, 09:19 PM Post #10 |
|
Member
![]() ![]() ![]() ![]() ![]()
|
If you have trouble with this one you could always make a request for an updated one in the requests section. |
![]() |
|
| DarkTamerx | Sep 1 2013, 07:55 AM Post #11 |
|
Member
![]() ![]() ![]()
|
I personally have used this for a while and haven't had any problems. |
![]() |
|
| Makaze | Oct 8 2016, 10:57 AM Post #12 |
|
Discordian
![]() ![]() ![]()
|
This sounds like a problem with the browser. There are no loops in my code and the event it uses is a built in feature of the browser (it is bound to the "on before unload" event). An alternative: it is possible that another script that does have loops is causing a conflict? |
![]() |
|
| Helena | Oct 8 2016, 12:07 PM Post #13 |
![]()
M is for Mod
![]()
|
For those that might not be aware, there are browser extensions available that will back up your textarea inputs for you. Lazarus is a good one in FireFox, for instance. Its saved me a lot of grief. |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · ZetaBoards Codes & Modifications · Next Topic » |
| Track Topic · E-mail Topic |
4:33 AM Jul 11
|



![]](http://b1.ifrm.com/0/1/0/p601690/pipright.png)









4:33 AM Jul 11