Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6547867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:53:00+00:00 2026-05-25T11:53:00+00:00

How can I show a message like a popup modal if a user has

  • 0

How can I show a message like a popup modal if a user has entered some content and then not saved it and try to leave the page?

Something like:

enter image description here

This appears if you try to go to another page within Facebook BUT if you type in the URL then you get a native alert box like:

enter image description here

1.) What is the difference? Is the alert something that is built into browsers?

2.) How can I use jQuery to create my own custom modal boxes when similar events happen?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:53:00+00:00Added an answer on May 25, 2026 at 11:53 am

    Since you’re using jQuery for this, I would attach the default values to each elements data holder, then using the onbeforeunload code above check all the current values against the stored original values… An example:

    $(document).ready(function() {
        $('#formID input').each(function() {
    
            $(this).data('original', $(this).val());
    
        });
    });
    
    window.addEventListener('beforeunload', beforeUnload, true);
    $(".submit").click(function(){
        window.removeEventListener('beforeunload', beforeUnload, true);
    
    });
    

    THEN:

    function beforeUnload(e) {
        $('#formID input').each(function() {
    
            if($(this).data('original') != $(this).val()) {
                return "You have unsaved changes!";
            }
    
        });
    }
    

    This code will work for INPUT tags, You would have to modify it to do similar checks against textarea and select elements as needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://tinypic.com/r/5dv7kj/7 How can i show the message like in the picture(top right)? I'm new
How can I show an confirmation message in Actionscript 3 ? I use Adobe
We need a user control that can show Microsoft Office files (Word, Excel..). There
i need to show an asp.net page with a message like Your download will
presently i am playing with rails3.Can it possible to show a message likeSorry ,
How can I show a message when say something is deleted and it appends
I wants to display the error message like, The following headers not avail 1.Name
I'm developing a website in php. I want to show a message something like
how can I show users success/error messages without creating a node for it? Thanks
can anyone recommend a website crawler that can show me all of the links

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.