Jump to content
Sign in to follow this  
searle

Insert IE Head Element

Recommended Posts

searle

I am looking to insert a new script node into the head element within IE, although I'm not sure how best to go about approaching this.

My thought process was as follows:

$oHead = $oIE.document.body.GetElementsByTagName('head')
$oHead = $oHead[0] ;  takes first element, which should be the only one returned

$oScriptNode = $oIE.document.body.createElement('script')

; fill script node element with text

$oHead.appendChild($oScriptNode)

That is more pseudo-code than anything at this point, but it's my starting point.

Does anyone have any suggestions on how to proceed?

Share this post


Link to post
Share on other sites
searle

And right after I posted this, I solved my own problem:

dim $def = "body {background-color: red;}"
dim $oHead = $oExplorer.document.getElementsByTagName('head')(0)
dim $oStyle = $oExplorer.document.getElementsByTagName('head')(0)

$style.setAttribute("type", "text/css")
$style.styleSheet.cssText = $def

$oHead.appendChild($style)
Edited by searle

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×