Solved

onbeforeunload unless i press submit

Posted on 2011-09-15
6
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

735 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