JQuery - confirm () not working in IE
I have a lightweight script that works in all browsers except IE (8, haven't tried lower versions yet).
$('.deleteItemIcon').click(function() {
var deleteConfirm = confirm('Do you really wanna delete that item?')
if (!deleteConfirm) {
return false;
}
});
Can you see the reason why this shouldn't work, if so how to get it to work?
a source to share
Just curious, for those who don't work with this code ... are you using IETester? I had a few problems with IE8 (when using IETester) and once I actually took 20 minutes to upgrade to ie8 I found the code worked ... Just a thought. One more note, I went through and made sure IETester is fully updated and still have issues. Acknowledgments and warnings don't work as expected (if at all ...) for ie8.
a source to share
$('.deleteItemIcon').click(function() {
return confirm('Do you really wanna delete that');
});
try this like
you don't need to specify the confirmation in the variable and check it after returning false. Confirm already returns true
or false
so you can just return the result confirm()
.
a source to share
My HTML:
<a href="/default.aspx?mode=Reset" id="rstPrtlts">Reset to default layout</a>
This works in Chrome, but not IE:
$('#rstPrtlts').click( function() {return confirm('This will reset your widgets on the homepage. Are you sure?');});
However, I have very similar code on the page that works. It's worth noting that the code I mean is a .js file downloaded from a static server.
This works in both Chrome and IE:
$('#rstPrtlts').click( function(e) {if(confirm('This will reset your widgets on the homepage. Are you sure?')) { window.location = e.currentTarget.href;}});
Not sure why the first code won't work. I've heard several reasons IE blocks functions that always return false, etc. Etc.
a source to share