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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:40:28+00:00 2026-06-12T03:40:28+00:00

I am working on a Javascript that is suppose to do a click feature

  • 0

I am working on a Javascript that is suppose to do a click feature on an element as well as showing a pop-up asking if you want to really leave the site (close the tab). Now The code works fine on IE and Firefox. But Chrome while it does do the important thing in terms of doing the click(); It will not show a pop-up asking if I want to leave or not. I Don’t know if its a feature I need to enable in the Chrome browser or something else. Here is the code I am using. Any help would be much appreciated.

var validNavigation = false;

function wireUpEvents() {

  var dont_confirm_leave = 0; 
var leave_message = document.getElementById("kioskform:broswerCloseSubmit");
      function goodbye(e) {
        if (!validNavigation) {
          if (dont_confirm_leave!==1) {
            if(!e) e = window.event;
            //for IE
            e.cancelBubble = true;
            e.returnValue = leave_message.click();
            //e.stopPropagation works in Firefox.
            if (e.stopPropagation) {
              e.stopPropagation();
              e.preventDefault();
            }
            //return works for Chrome and Safari
            return leave_message.click();
            alert("Removing information.");
            //add the code to delete the kiosk information here.
            // this is what is to be done.
          }
        }
      }
      window.onbeforeunload=goodbye;

      // Attach the event keypress to exclude the F5 refresh
      jQuery('document').bind('keypress', function(e) {
        if (e.keyCode == 116){
          validNavigation = true;
        }
      });

      // Attach the event click for all links in the page
      jQuery("a").bind("click", function() {
        validNavigation = true;
      });

      // Attach the event submit for all forms in the page
     jQuery("form").bind("submit", function() {
        validNavigation = true;
      });

      // Attach the event click for all inputs in the page
     jQuery("input[type=submit]").bind("click", function() {
        validNavigation = true;
      });

    }

    // Wire up the events as soon as the DOM tree is ready
    jQuery(document).ready(function() {
      wireUpEvents();
    });
  • 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-12T03:40:29+00:00Added an answer on June 12, 2026 at 3:40 am

    You have to return a string in the onbeforeunload function to show the message to the user, see also Setting onbeforeunload on body element in Chrome and IE using jQuery

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

Sidebar

Related Questions

Hello all I am working in javascript and html5.I want to ask that how
In the website I am working on there is a javascript pop-up (jquery) that
Hello I am working on a javascript that is suppose to test the password
I am working on a Javascript object that contains some YUI objects. The key
I'm currently working on a JavaScript project that uses the HTML5 canvas as a
As I've starting working with Javascript, I learned the hard way that when you
I am working on a php program that requires javascript on every form control.
When working on some Javascript for a web application, I noticed that I had
I'm working on a PHP script that compiles a JavaScript framework. Right now I'm
I'm working on a web application that has a lot to download (javascript, images,

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.