I've written some very simple code on Internet Explorer 8 and I don't understand why nothing happens when I open the page with IE (why the text 'test' doesn't appear on the page).
I've tried on Firefox and Chrome and it works perfectly.
my code :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso 8859-1" />
<script type="text/javascript">
function display() {
output.innerHTML+='test';
}
</script>
</head>
<body onload="display()">
<div id="output">
</div>
</body>
</html>
Edit : let IE change your setting, don't do it by hand or it gets weird :-))
I've written some very simple code on Internet Explorer 8 and I don't understand why nothing happens when I open the page with IE (why the text 'test' doesn't appear on the page).
I've tried on Firefox and Chrome and it works perfectly.
my code :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso 8859-1" />
<script type="text/javascript">
function display() {
output.innerHTML+='test';
}
</script>
</head>
<body onload="display()">
<div id="output">
</div>
</body>
</html>
Edit : let IE change your setting, don't do it by hand or it gets weird :-))
Share Improve this question edited May 11, 2011 at 13:57 Bruno asked May 11, 2011 at 13:36 BrunoBruno 9,10713 gold badges40 silver badges55 bronze badges 4-
As mentioned in the answers already,
document.getElementById
is the usual method of getting a handle on an element from the document. Does this work for you; jsbin./uqama4? It works for me on Vista/IE 8 – Andy E Commented May 11, 2011 at 13:40 - I would re-install IE 8, or upgrade to IE 9. – Andy E Commented May 11, 2011 at 13:45
- Works fine in IE8 for me. Have you turned JS off in your installation of IE or something? – ADW Commented May 11, 2011 at 13:49
- 1 one thing that pops in my mind is active x is not enabled or JS disabled – KJYe.Name Commented May 11, 2011 at 13:52
2 Answers
Reset to default 3document.getElementById('output').innerHTML += 'test';
Try:
function display() {
document.getElementById('output').innerHTML+='test';
}