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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:55:39+00:00 2026-06-10T13:55:39+00:00

As usual, I want to alert users to unsaved changes when leaving a page.

  • 0

As usual, I want to alert users to unsaved changes when leaving a page. I have this test page:

<html>
<head>
<title>Testing</title>
<script language="JavaScript1.1" src="https://127.0.0.1:8443/scripts/base.js"></script>
<script language="JavaScript1.1" src="https://127.0.0.1:8443/scripts/edit.js"></script>
<script language="JavaScript1.1">window.onbeforeupload=moveAway</script>
</head>
<body onLoad="init()">
<a href="http://www.google.com">Google</a>
</body>
</html>

The moveAway function is defined in “edit.js” like this:

function moveAway ()
  return "foo";<br>
}

The event doesn’t fire, or at least it just leaves the page silently (using IE8, Firefox 15, and Chrome 20). I’ve tried breakpointing the function in Firebug and it never gets to the breakpoint. I’ve tried it from the web server (an SSL server, the test version of which runs at 127.0.0.1:8443) and I’ve tried opening the file directly with the browser (which is why I used absolute URLs for the first two <script> tags). I’ve tried removing the “src=” attribute from the script tags.

On the other hand, this page has an example which does work (at least in Firefox):

https://web.archive.org/web/20211028110528/http://www.4guysfromrolla.com/demos/OnBeforeUnloadDemo1.htm

There is also a very similar example at MSDN which also works:

http://msdn.microsoft.com/en-us/library/ms536907%28VS.85%29.aspx

I really can’t see the difference between what they do and what I’m doing. can anyone tell me why their code works and mine doesn’t?

  • 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-10T13:55:40+00:00Added an answer on June 10, 2026 at 1:55 pm

    onbeforeupload , really ? it should be onbeforeunload. Is that a spelling mistake, or is that how your actual code is ?

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

Sidebar

Related Questions

I want to trigger a form submit, but not have my usual handlers for
I want to link from my project Trac page to my javadoc index.html file,
I have some action and I don't want to use usual layout for it.
The usual solution when you create routes in symfony and you want to have
I want to do something like this: $query=mysql_query(SELECT userid FROM users WHERE username='$username'); $the_user_id=
I have the usual Jquery datepicker working fine. But I want to feed it
I'm passing an XElement to my Edit view and want to have the usual
I have a menu, created from the usual unordered list, that I want to
I want sections would have same behavior as cells when I drag it. Usual
I want to make preview button as usual form button next to submit button(as

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.