Solved

onbeforeunload unless i press submit

Posted on 2011-09-15
6
374 Views
Last Modified: 2012-05-12


Hello all

im not a java geek maybe somone can help me

i have this page:
<head>
<title>Untitled Document</title>
<script type="text/javascript">
        function OnBeforeUnLoad () {
            return "Sure you want to exit ?";
        }
    </script>
</head>
<body onbeforeunload="return OnBeforeUnLoad()>
    <form action="" method="get" name="test">
        <input name="test1" type="text" />
        <input name="b1" type="button" />
    </form>
</body>
</html>

now when i exit the page or press submit i get sure you want to exit is it posible to disable message if i press submit ? and only showing it when i try to exit page
0
Comment
Question by:nova-c
  • 2
  • 2
6 Comments
 
LVL 13

Expert Comment

by:ansudhindra
Comment Utility
your code is missing a double quote on line

<body onbeforeunload="return OnBeforeUnLoad()>

try the below code..
 
<head>
<title>Untitled Document</title>
<script type="text/javascript">
        function OnBeforeUnLoad () {
            if(confirm("Sure you want to exit ?")){
              return true;
            }
            return false;
        }
    </script>
</head>
<body onbeforeunload="return OnBeforeUnLoad()">
    <form action="test.html" method="get" name="test">
        <input name="test1" type="text" />
        <input name="submit" type="submit" />
    </form>
</body>
</html>

Open in new window

0
 

Author Comment

by:nova-c
Comment Utility
oki thx that was a error when i typed the code here, the code workes on the homepage
but i want it to disable the code when i press the submit button
0
 
LVL 13

Accepted Solution

by:
ansudhindra earned 500 total points
Comment Utility
As far I know it is not possible because, when you submit the form, page reloads..
0
 

Author Comment

by:nova-c
Comment Utility
it must be posible to disable the function in java when i press submit
0
 
LVL 31

Expert Comment

by:James Murrell
Comment Utility
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Add pin/tack to Google Map 3 61
Log In into DNN with Gmail Account 3 49
PDF links 3 44
Popup window in I.E. 8 35
Bada platform is becoming more and more famous this days and people talking about same. Some friends included those who have bada OS mobile asked me "what is bada?"and "what its features?". That encouraged me to research and write this article. [st…
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now