Version: (using KDE KDE 3.5.7) Installed from: Unspecified Linux OS: Linux This is a very strange one, took me a while to track it down... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>addEventListener bug</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript"> <!-- function init(e) { if (e && e.type=='DOMContentLoaded') { alert('DOM Loaded'); } else { alert(this); // Finding the currect object alert(this.onclick); // But not it's onclick value? } } function addOnclick(el, evt) { el.onclick=init; } if (document.addEventListener) { // Unknown even to Konqueror so should have no effect on the script. document.addEventListener('DOMContentLoaded', init, false); // But when removed, the script runs as it should. } function clickTest() { addOnclick(document.getElementsByTagName("p")[0]); } window.onload=clickTest; //--> </script> </head> <body> <h1>Example</h1> <p>Click me!</p> </body> </html>
Doesn't have to be unknown, any addEventListener would do, I think --- it gets confused because the same listener function is used as both a legacy HTML-style listener and real one.. That code looks bogus, but I don't know what it's trying to do..
Right you are any event messes it up (sorry I should have tested with some standard ones). Bogus code? Yeah I was just trying to show the bug, the propper script was a custom event listener & DOMReady script, which I then decided I'd make it trigger the click even of any #bookmark in the URL after the DOMReady scripts had loaded (it works quite nicely if I do say so myself :)). Anyway none of the other browser I tested in (FF and Opera) have a problem with this. I've already worked around it, I just thought you amazing KDE Dev's (I'm a big fan ;)) would want to know.
By bogus code I meant the one in KHTML, not your example :-)
Created attachment 24507 [details] The above testcase so you can easily go clicky click same testcase, easier to click Is this supposed to work now?
fixed in SVN by vtokarev