Does anyone know of a workaround for the bug in IE9 where a function in the onclick for these page elements: button, div, img, isn't called? So you click on the element and nothing happens. This came up on a page that I am developing. If I launch the F12 debugger, the problem goes away. But I cannot ask site visitors to click F12 to browse the page! What are the solutions to this? I thought that this might only happen when the element is created dynamically in javascript. But this also happens if the element is defined in the HTML.
Does anyone know of a workaround for the bug in IE9 where a function in the onclick for these page elements: button, div, img, isn't called? So you click on the element and nothing happens. This came up on a page that I am developing. If I launch the F12 debugger, the problem goes away. But I cannot ask site visitors to click F12 to browse the page! What are the solutions to this? I thought that this might only happen when the element is created dynamically in javascript. But this also happens if the element is defined in the HTML.
javascript
html
internet-explorer-9
Share
Improve this question
asked May 16, 2012 at 14:27
user823527user8235273,7121717 gold badges6969 silver badges111111 bronze badges5
2Can you post your code to give more context please?
– Brian Geihsler
CommentedMay 16, 2012 at 14:29
have you tried binding the click event with jQuery? Maybe that could solve the problem and make it more IE safe.
– Odinn
CommentedMay 16, 2012 at 14:30
IE9, for basic things, works very similarly to other browsers now. Check your headers : stackoverflow./questions/10305631/…
– Denys Séguret
CommentedMay 16, 2012 at 14:31
I was wondering if anyone was aware of the problem and if there was an explanation for it. This is something that turned up recently and before changing all the buttons, images to bind the click event, I thought I'd ask.
– user823527
CommentedMay 16, 2012 at 14:32
I think you should be checking for a bug in your code.
– tzerb
CommentedMay 16, 2012 at 14:37
Add a ment
|
2 Answers
2
Reset to default
6
You mentioned that the code works if the user has the developer tools open, which means your problem is most likely that you are using console.log statements in your code.
in IE, printing to the console when the developer tools are not open will cause a javascript exception, which would cause your event handlers to stop working.
to get around this problem, wrap all of your console statements with an if statement:
if (console) {
console.log('foo');
}
Use jQuery, e.g.
$('#myButton').click(function() {
// code goes here
});
This will work out the correct code to fire the click event.
发表评论