views:

955

answers:

2

I'm working with CMS i'can't edit source of . can i add any in through javascript?

Edit:

For example I want to add this

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

just above <title>

+7  A: 

You can select it and add to it as normal:

$('head').append('<link />');
nickf
+1 will try this
metal-gear-solid
how can i control order , where this link will be placed
metal-gear-solid
Read the documentation: http://docs.jquery.com/Manipulation `insertBefore`, `insertAfter` is what you want.
nickf
+1  A: 

jQuery

$('head').append( ... );

JavaScript:

document.getElementsByTagName('head')[0].appendChild( ... );
David Hedlund
dosen't appendChild require a DOM-element? ie. var elem = document.createElement() document.getElementsByTagName('head')[0].appendChild( elem );
fredrik
well yes. i just left that part as `...` because i didn't feel that was a central part of the question, and also, at the time of writing, there was no hands-on example as to what he wanted to put in head. but yes, it does need to be a DOM-element.
David Hedlund