The following JavaScript works fine in MediaWiki 1.17.1, when placed into a ResourceLoader-loaded module, producing an alert box:
addHandler(window, 'load', function() { alert('hello'); });
However, the same code does not seem to run in MediaWiki 1.18.0 in Internet Explorer 8: no alert box is displayed. (It still works in Firefox though.)
Anybody know why?
I have confirmed, using IE Developer Tools, that window.addHandler is defined in IE after the page loads, by typing "addHandler.toString()" in the console:
addHandler.toString()
"function(element,attach,handler){if(element.addEventListener){element.addEventListener(attach,handler,false);}else if(element.attachEvent){element.attachEvent('on'+attach,handler);}}"
Thanks, DanB
On Thu, Dec 22, 2011 at 7:28 PM, Daniel Barrett danb@vistaprint.com wrote:
The following JavaScript works fine in MediaWiki 1.17.1, when placed into a ResourceLoader-loaded module, producing an alert box:
addHandler(window, 'load', function() { alert('hello'); });
However, the same code does not seem to run in MediaWiki 1.18.0 in Internet Explorer 8: no alert box is displayed. (It still works in Firefox though.)
Anybody know why?
You probably need to do window.addHandler( .. ) instead? Alternatively, use jQuery to bind events. If you just want to do something upon document ready, use:
jQuery( document ).ready( function() { ... } ); or even jQuery( function() { ... } );
Roan
Roan Kattouw wrote:
You probably need to do window.addHandler( .. ) instead? Alternatively, use jQuery to bind events. If you just want to do something upon document ready, use:
jQuery( document ).ready( function() { ... } ); or even jQuery( function() { ... } );
Thanks Roan. I used your jQuery implementation in place of addHandler, and it worked fine. I still don't know why addHandler didn't work (neither did window.addHandler).
DanB
wikitech-l@lists.wikimedia.org