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 8091895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:10:09+00:00 2026-06-05T20:10:09+00:00

I am creating a HTML layout where user can fill the data and save

  • 0

I am creating a HTML layout where user can fill the data and save that page in HTML and JSON formats by using “save” and “save as draft” resp. Can i use

window.onbeforeunload

twice in my template.html file to show two different alert messages?

The alerts would show:

  • when page is empty and user tries to go to load another page
  • when user fills the data in the layout and tries to leave the layout without saving
  • 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-06-05T20:10:10+00:00Added an answer on June 5, 2026 at 8:10 pm

    At first see this example to to understand what will happen if you use it twice, then the idea given bellow

    window.onbeforeunload=function()
    { 
        if(form_empty())
            return "Form is empty"; // message for empty form 
        else
            return "Form is not empty"; // message for filled up form 
    }
    
    function form_empty()
    {
        // check form fields whether the form is empty or not
        // return true if form is empty
        // return false if form is not empty
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using javascript, I'm creating some html content--some nested divs that are styled via a
I am creating html dynamically using perl, mysql and JS/Jquery ... the basic structure
I have a scenario that, I am creating dynamic html content and I need
I have a website that right now, runs by creating static html pages from
I am creating a 404.html page in django which will be called when i
I am creating a registration page in HTML, PHP, and MySQL. I want to
I'm creating a mobile site next to our normal html site. Using rails 3.1.
When using UiBinder what is the preferred method of creating a simple layout like
I'm creating a html-layout based on an existing layout. I want to extract all
I am creating WP theme with responsive layout based on twitter bootstrap. You can

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.