Forum Moderators: open
I've used various methods of adding the onClick to the DIV but IE6 refuses to accept it. All methods I've used work perfect in FF (which is no good because I have a contentEditable DIV which is not supported in FF).
Here is the first code I used:
var div = document.createElement('DIV');
div.contentEditable = true;
var attr = document.createAttribute('onClick');
attr.value = "alert('hello')";
div.setAttributeNode(attr);
Second Method:
var div = document.createElement('DIV');
div.contentEditable = true;
div.setAttribute("onClick", "alert('helo')");
Third Method:
var div = document.createElement('DIV');
div.contentEditable = true;
div.id = "myDiv";
document.getElementById('myDiv').setAttribute("onClick", "alert('helo')");
All of the above methods should create this:
<DIV contentEditable="true" onClick="alert('hello')"></DIV>
Any ideas?