Show warning when the browser is closed while drafting
+3
TheCrow
Ange Tuteur
Zzbaivong
7 posters
Page 1 of 1
Show warning when the browser is closed while drafting
Imagine that when you're writing articles, then open another tab to relax. After a while you forget about it, and close the browser, so, your article is zero. This code will cause a warning modal to appear in the browser if you refresh, close the tab... before posting. It looks like this:
Make sure Javascript code management is enabled then Create a new javascript.
Title * : Show warning when the browser is closed
Placement : In all the pages
Javascript Code * :
You can translate this text:
Installation
Go to ACP >> Modules >> HTML & JAVASCRIPT >> Javascript codes managementMake sure Javascript code management is enabled then Create a new javascript.
Title * : Show warning when the browser is closed
Placement : In all the pages
Javascript Code * :
- Code:
/* Show warning when the browser is closed - by Zzbaivong */
$(function() {
$(function() {
if ($.sceditor) {
var $win = $(window),
$editor = $("#text_editor_textarea").sceditor("instance"),
firstVal = $editor.val();
$win.on("beforeunload", function() {
if ($editor.val() !== firstVal) return "Your post may not be saved.";
});
$("form[name='post']").on("submit", function() {
$win.off("beforeunload");
});
}
});
});
You can translate this text:
- Code:
Your post may not be saved.
Last edited by Zzbaivong on July 3rd 2015, 5:21 am; edited 1 time in total
Re: Show warning when the browser is closed while drafting
And this works for all versions?
Guest- Guest
Re: Show warning when the browser is closed while drafting
Yes, as long as you are using SCEditor.Draxion wrote:And this works for all versions?
Re: Show warning when the browser is closed while drafting
Very nice, it works well from what I tested.
Yes, it should as it only targets elements which are present globally across each version. As long as you haven't removed the SCEditor, all is well.Draxion wrote:And this works for all versions?
Re: Show warning when the browser is closed while drafting
Installed! Works perfectly! Thanks @Zzbaivong! Great Job!
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Re: Show warning when the browser is closed while drafting
@Zzbaivong
Yes, it works great!
Effective in the moments when we change the tab and forget what we were doing and then close the browser...
JS
Yes, it works great!
Effective in the moments when we change the tab and forget what we were doing and then close the browser...
JS
Pizza Boi- Hyperactive
- Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!
Re: Show warning when the browser is closed while drafting
Find:Pizza Boi wrote:Hi
It doesn't work for my test forum . Editor's okay.
http://rletf.forumtl.com/
Regards,
Pizza Boi
- Code:
$(function() {;
- Code:
$(function() {
Re: Show warning when the browser is closed while drafting
Hi
It still doesn't work ;-;
Regards,
Pizza Boi
It still doesn't work ;-;
Regards,
Pizza Boi
Pizza Boi- Hyperactive
- Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!
Re: Show warning when the browser is closed while drafting
Love this feature. With my site being for roleplay this helps a lot.
Thank you for this code!
Thank you for this code!
Similar topics
» SSL on browser don't show.
» I gave Michael's family consent to run my forums
» icon for closed?
» [closed]In need of a banner
» My forum will be closed.
» I gave Michael's family consent to run my forums
» icon for closed?
» [closed]In need of a banner
» My forum will be closed.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum