Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 1

HELP with showing warning when closing browser?


MansidakS

Question

Site URL: https://www.frostwriter.com

Hi!

I have a website where there is a <textarea> tag is being used. It basically allows the user to type in something and download the content as a txt file. I wish to add a feature that shows a dialog box in the browser which asks "Are you sure you wish to close the browser without saving your work"? I want to add this so that the user doesn't lose their content and can be reminded to download it before leaving the page or refreshing the page. I saw some similar questions in stack exchange but neither of them worked on Squarespace.

 

Any kind of help would be really appreciated! Thanks in advance! 

Link to comment

6 answers to this question

Recommended Posts

  • 1
On 11/11/2020 at 7:35 PM, cmpnd said:

Could you pretty please post the js function?

You can do this with the onbeforeunload event. It allows you to display a "Leave site?" confirmation dialog box when the user tries to leave the current page. The message is determined by the browser.

You add use this event by adding the following code to the code injection area, or by adding it to a Code Block on a specific page.

<script>
window.onbeforeunload = function(event) {
  event.returnValue = "Changes that you made may not be saved.";
};
</script>

   If a post helps you, please click a "Like" option below  ↘️

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 1

Looks like you have solved this.

1345960804_Screenshot2020-05-19at15_47_04.thumb.png.c3cdcdffa8da465512110e27a67debdc.png

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0

Could you pretty please post the js function? I'm working on accessibility updates and I've come across a point that I don't think I can figure out without this js function. 

"Users must be warned of any timeout that could result in data loss, unless the data is preserved for longer than 20 hours of user inactivity. "

If you can share your solution, that would be greatly appreciated. Also, I rather like frostwriter, so great job with that.

 

Designer and lover of all things.

Link to comment
  • 0
19 hours ago, cmpnd said:

Could you pretty please post the js function? I'm working on accessibility updates and I've come across a point that I don't think I can figure out without this js function. 

"Users must be warned of any timeout that could result in data loss, unless the data is preserved for longer than 20 hours of user inactivity. "

If you can share your solution, that would be greatly appreciated. Also, I rather like frostwriter, so great job with that.

 

Have you found the code yet?

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
23 hours ago, tuanphan said:

Have you found the code yet?

I've been searching like crazy and so far none of my queries are bringing anything up thats useful. If/When I do find the code, I'll post here. 

Designer and lover of all things.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...