Solved

onbeforeunload unless i press submit

Posted on 2011-09-15
6
378 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
ID: 36542302
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
ID: 36558315
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
ID: 36558609
As far I know it is not possible because, when you submit the form, page reloads..
0
 

Author Comment

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

Expert Comment

by:James Murrell
ID: 37163565
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Gmail Account risks 4 95
Cookie issue 7 141
How to open a zip file 4 100
Browser annoying behavior 18 61
Problem I downloaded the Microsoft Internet Explorer 9 Beta, today, to give it a test drive and maybe write a review for the site, and it failed miserably and got stuck in a crash restart loop. The error message given is as illustrated below i…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

856 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