Vista, IE7, and cancelling an onclick event

C

Chris Walls

If there is a better newsgroup for this, please let me know. I also cannot
seem to get to the MSDN forums; the page never loads...

We have an ASP.NET 2.0 application that uses the AJAX Extensions and the
AJAX Control Toolkit. Many of our pages use JavaScript confirm dialogs for
standard "Are you sure" messages. One of our users is running IE 7 on Vista
Business. The following code displays the confirm correctly, but the cancel
response is essentially ignored and the user is taken to page2.html. This
exact same code works on Vista Home Premium w/IE 7 and WinXP w/IE, Firefox,
Opera, and Safari. It also works on the Vista Business machine with
Firefox, so we are fairly certain this is an IE 7 / Vista Business issue.

Any thoughts on what it could be? We perused the options available for IE
and none drew our attention as being a possible culprit. The other
JavaScript code in the application has been executing as expected.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Page 1</title>
</head>
<body>
<form action="Page2.htm" method="post">
<h1>You are now on page 1</h1>
<input type="submit" onclick="return confirm('Are you sure you want to go
to page 2?');" value="Click here for page 2">
</form>
</body>
</html>



************* Page2.htm ****************
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<h1>You are now on page 2</h1>
<a href="Page1.htm">Back To Page 1</a>
</body>
</html>
 
M

Mike Placentra II

If there is a better newsgroup for this, please let me know. I also cannot
seem to get to the MSDN forums; the page never loads...

We have an ASP.NET 2.0 application that uses the AJAX Extensions and the
AJAX Control Toolkit. Many of our pages use JavaScript confirm dialogs for
standard "Are you sure" messages. One of our users is running IE 7 on Vista
Business. The following code displays the confirm correctly, but the cancel
response is essentially ignored and the user is taken to page2.html. This
exact same code works on Vista Home Premium w/IE 7 and WinXP w/IE, Firefox,
Opera, and Safari. It also works on the Vista Business machine with
Firefox, so we are fairly certain this is an IE 7 / Vista Business issue.

Any thoughts on what it could be? We perused the options available for IE
and none drew our attention as being a possible culprit. The other
JavaScript code in the application has been executing as expected.

As it seems you're working directly with the HTML form element anyway,
I'd suggest putting your confirm JavaScript in the form's onSubmit
attribute (onsubmit xHTML of course).

-Michael Placentra II
 
B

bruce barker

IE has a long standing bug where this happens (back to 5.5). Never sure
what triggers it, you will find it works on another box with the same
software.

anyway the fix is easy, but causes trouble if you need event bubbling
(not in your case). add the following function to your page:

function cancelEvent()
{
// ie only hack
if (window.event) window.event.cancelBubble = true;
// everyone else
return false;
}

then change your onclick to:

<input type="submit"
onclick="if(!confirm('blah...'))return cancelEvent();"
value="Click here for page 2">



-- bruce (sqlwork.com)
 
S

Steven Cheng[MSFT]

Hi Chris,

As other members have mentioned, the problem is likely tighted to the
certain machine. I've also tested the pages on my local box(with VISTA
business + IE7), the cancel behavior works correct(won't navigate to
page2). You can also try it on some other boxes to see the behavior.
Also, will the other alternative suggestions mentioned work for you?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
C

Chris Walls

We've been using the same basic JavaScript library for going on 10 years now
and this is the first time we've experienced this. Bruce's suggestion may
work for us so we'll give that a shot. The problem with Mike's sugestion is
that it only addresses the simple example. We have application pages with
multiple buttons that require different types of user confirmation, plus we
have other functionality hooking into the form's onsubmit event.

Is there anything we can provide to MS to help diagnose the problem? We've
found several posts where someone complained about the same issue, though
each posting had responses from others that they could not reproduce the
issue with the same software configuration. So we believe this is an issue,
though obviously very difficult to reproduce.

Thanks to all for the suggestions.

- Chris
 
S

Steven Cheng[MSFT]

Hi Chris,

Yes, the bigest problem here is such problems are quite hard to repro. For
MS product support guys to troubleshoot on this, it will surely need to
have stable reproable environment so as to perform tests. Also, normally,
they'll peform tests on local side first, but as you know, such problems is
not likely to be reproable there.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: "Chris Walls" <[email protected]>
Subject: Re: Vista, IE7, and cancelling an onclick event
Date: Fri, 5 Oct 2007 10:09:18 -0500
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top