JavaScript Trap User for Unsaved Work Tutorial Textarea Check

Lesson Code:
Learn to program a Trap user application like Youtube and Facebook have using JavaScript if the user has unsaved work or has not posted text they have written in.


16 thoughts on “JavaScript Trap User for Unsaved Work Tutorial Textarea Check”

  1. one comment..
    why would someone want to "trap"a user??
    say they were uploading multiple files with multiple fields a time… they leave, all the info is lost
    THATS when you fire it off

  2. youTube has a betterway.

    It allows to go over but not submit. This gives users a chance to finish and edit with no hassle; otherwise, the user has to start editing before they even finish.This causes displaced thoughts and is an unpleasant experience.

    If you want more users to submit think SEO, "user experience is everything". Users do move on without submitting when challenged. In most of these situation the user is very close to having finished.

    How about a vid on this doing like youtube?

  3. How do you customize the window that pops up like facebook has done? Many a time I've needed customized pop-up windows, but I've never known how to make them!

    Absolutely fantastic videos Adam by the way!!!!!! THANK YOU SO MUCH!

  4. Nice tutorial! I always wondered how they did that.

    Just an addition to this tutorial: If the user enters text into the text field, and then clicks the submit button, this script will still fire, even though the user is taking the proper exit route (posting content). So, you have to disable the window.onbeforeunload event when the submit button is clicked, like this:

    var submitButton = document.getElementById('submit');
    submitButton.onclick = function(){
    window.onbeforeunload = null;

  5. Hello Adam,

    I have carefully followed the "PayPal Buy now button" tutorial and I have no code errors, but when I test the link it just takes me to the paypal website (no payment instructions to the customer).

    I have been trying to fix this for months, and I really did not want to bother you, but i don't know what else to do.

    Thanks for all the tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *