Bruno
Bruno

Reputation: 9037

Onload event not working with Internet Explorer

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 :-))

Upvotes: 3

Views: 4391

Answers (2)

James McCormack
James McCormack

Reputation: 9954

document.getElementById('output').innerHTML += 'test';

Upvotes: 3

KJYe.Name
KJYe.Name

Reputation: 17169

Try:

   function display() {
      document.getElementById('output').innerHTML+='test';
   }

Upvotes: 3

Related Questions