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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:16:48+00:00 2026-05-31T20:16:48+00:00

I am working on a enterprise application where forms a generated dynamically and we

  • 0

I am working on a enterprise application where forms a generated dynamically and we don’t have control over the code. Most of the controls in the form have following code associated to them

<select name="s_10_1_1_0"  onchange = 'SWESubmitForm(document.SWEForm10_0,s_5,"","1-E0RHB7")' id='s_10_1_1_0' tabindex=1997 >

<input type="text" name='s_10_1_11_0' value=''  onchange = 'SWESubmitForm(document.SWEForm10_0,s_7,"","1-E0RHB7")' id='s_10_1_11_0' tabindex=1997  maxlength="30">

We would like to present an ok cancel dialog when user tries to navigate to some other page using the link in the header or footer.

I have used to following code to bind onbeforeunload event and present an ok cancel dialog to user.

//this identifies the unique page name
var viewName = $('input[name="SWEView"]').val(); 
// if I am on desired page bind the event so that now dialog is presented to user
 if(viewName == "XRX eCustomer Create Service Request View"){
     $(window).bind('beforeunload', function(){
     return 'Your Inquiry has not been submitted yet.';
});
 }

But the problem is that this dialog comes every time user changes a value of any field in the form (I believe that is due to SWESubmitForm code present for onchange event).

I would like to onbeforeunload dialog to come if user clicks any other link outside form or in other words tie onbeforeunload to selective events (including closing the window) on the page.

Please Help

  • 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-31T20:16:49+00:00Added an answer on May 31, 2026 at 8:16 pm

    .onbeforeunload() is global. You can’t have it trigger for only some ways of leaving the page. If the event handler is installed it will trigger no matter how the viewer is leaving the page.

    You can keep track of your own internal state and decide whether to prompt anything in the onbeforeunload() handler or just return nothing (so no prompt is made).

    So, you could have code like this:

    //this identifies the unique page name
    var viewName = $('input[name="SWEView"]').val(); 
    // if I am on desired page bind the event so that now dialog is presented to user
    if(viewName == "XRX eCustomer Create Service Request View"){
        $(window).bind('beforeunload', function() {
            // figure out whether you need to prompt or not
            if (myStateSaysToPrompt) {
                return 'Your Inquiry has not been submitted yet.';
            } else {
                return;   // no prompt
            } 
       });
    }
    

    Update

    As this is quite high on google getting many views it would be worth noting that this answer no longer works.

     $(window).bind('beforeunload', function() {
    

    Note that there is no longer ‘on’ in the event being bound. Using the previous onbeforeunload in later versions of jQuery will result in nothing happening.

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

Sidebar

Related Questions

I'm working locally across two domains. I have enterprise.local and application.local virtual hosts on
I have create an iPad application for enterprise distribution and its working very well
I am working with v4 of the Enterprise Application block and I am trying
Suppose you're working on an enterprise project in which you have to get management
I've got a project that I'm working Enterprise Library logging into, and that application
I have an enterprise application running on a WebLogic server. When I modify any
I have a big application as an enterprise scale, there are lots of developers
I'working on a enterprise application that uses JSF 2.0, with Netbeans 7.0 and Glassfish
I'm working on an enterprise application that relies heavily on message queues, com+, databases,
I'm working on a user facing django application for an enterprise solution. Currently, users

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.