Looking at Compatibility changes in IE11, we have that window.execScript is replaced with eval. Now when using the IE COM object how can we get hold of the JavaScript Global Object that has the eval function?
PowerShell:
$ie = New-Object -COM InternetExplorer.Application
$document = $ie.document
$window = $document.parentWindow
# How to get JavaScript Global Object from these?
See also this related question.
IHTMLDocument::get_Script, I believe. You would need to callevalvia late binding.$ie.Document.Scriptthat points to the JavaScript Global Object. Do you have an example of using it using PowerShell or WSH? Thanks.IDispatch*thatIHTMLDocument::get_Scriptreturns is the global object. I'm not familiar with PowerShell. In WSH, just simplyie.Document.Script.eval('alert("Hi")')should work.$ie.Document.Script.eval('alert("Hi")')I get this error: Method invocation failed because [System.__ComObject] does not contain a method named 'eval'$window."alert".Invoke("Hi")or this$ie.document.Script."alert".Invoke("Hi")which works! In case ofeval, however, this doesn't work:$ie.document.Script."eval".Invoke('alert("Hi")')Error: You cannot call a method on a null-valued expression.