Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

onbeforeunload unless i press submit

Posted on 2011-09-15
6
Medium Priority
?
384 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 2000 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

I spend far too much time on the web keeping up with the news: politics, the environment, computer stuff, the Experts Exchange. It's never-ending. But many of the most informative web pages are overwhelmed with noise: scrolling banners, flashing tex…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
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.
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.

670 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