I am using a way to insert some javascript code in the page which works with all browsers but not with IE. Here is a sample: http://boxfly.free.fr/tmp/innerjs.html
The line which does not work properly with IE is:
ele.text = document.getElementById('DIV_js').innerHTML ;
If I change this line to:
ele.text = 'alert("Hello")' ;
It works. But I need to be able to insert code which is on a lot of lines, not only one line for displaying an alert, that's why I am using a DIV to contain the Javascript code... ;)
Does anyone know how to make this script work with IE:
<body>
<div id="DIV_js" style="display:none;">
var i = 'here' ;
function hello() {
alert('toto says ' + i) ;
}
</div>
<script>
var ele = document.createElement("script") ;
ele.type = 'text/javascript' ;
ele.text = document.getElementById('DIV_js').innerHTML ;
document.body.insertBefore(ele, (document.getElementsByTagName("div"))[0]);
</script>
<span onClick="hello();">Click to display alert</span>
</body>