MyBB Community Forums

Full Version: Notice/Popup when users accidentally close a tab/window before finishing their post
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,

well I tried to google this topic in many different ways, but I couldnt find any solution. I think it would be very handy if there's a popup/notice/warning whenever users close a page before finishing their text. Be it a new post, thread, edit, quick reply or PM, whenever users use the texteditor, there is the risk of losing all content when you accidentally close the tab/window.

I know that if you click on "return" in your browser, the text is still there and you can continue it, but that does not work if you close the window/tab completely, so a confirmation request before closing the tab would be extremely useful.

Can this be done via a function in javascript or via a plugin maybe?

Thanks Smile
You could add the below to these templates headers: newthread, newreply, editpost

<script language="JavaScript">
    window.onbeforeunload = confirmExit;
    function confirmExit() {
        return "Are you sure you want to close this page?";
    }
</script>
(2014-04-26, 12:10 AM)thexshadow Wrote: [ -> ]You could add the below to these templates headers: newthread, newreply, editpost

<script language="JavaScript">
    window.onbeforeunload = confirmExit;
    function confirmExit() {
        return "Are you sure you want to close this page?";
    }
</script>

Wow thanks you two. This was a great idea. It should be in the build as a regular feature that can be turned off or on. WordPress has this feature and it's saved my lime several times.

Spot on you two. Many thanks.

Auriel
No problem. Wouldn't want you loosing your limes. Toungue
(2014-04-26, 12:10 AM)thexshadow Wrote: [ -> ]You could add the below to these templates headers: newthread, newreply, editpost

<script language="JavaScript">
    window.onbeforeunload = confirmExit;
    function confirmExit() {
        return "Are you sure you want to close this page?";
    }
</script>

Im sorry but as much as this solution works when i close a tab, it also restricts me from posting. Everytime I click on "post" or "update post", it asks me if I'm sure to leave that page, and that is just annoying.^^ It should only ask this question if I close the tab all of a sudden, u know?