Append some HTML into the HEAD tag?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-04-20T15:21:27Z Indexed on 2010/04/20 15:23 UTC
Read the original article Hit count: 166

Filed under:
|
|

Hi!

I want to add some style to head tag in html page using javascript.

var h = document.getElementsByTagName('head').item(0);
h.innerHTML += '<style>a{font-size:100px;}</style>';

But when I run this code in IE8 I see this error message: Could not set the innerHTML property. Invalid target element for this operation.

Any ideas?

© Stack Overflow or respective owner

Related posts about html

Related posts about JavaScript