我认为InvokeScript
可能有效,但没有。
strHTML =
(
<!DOCTYPE html>
<html>
<head>
<script> function displayDate() { document.getElementById("demo").innerHTML=Date(); }</script>
</head>
<body>
<p id="demo" onclick="displayDate()">This is a paragraph. Click here.</p>
</body>
</html>
)
new WebBrowser(strHTML)
Class WebBrowser
{
__New(strHTML) {
static WB
Gui, New, Resize
Gui, Add, ActiveX, vWB w780 h580 , Shell.Explorer
Gui, show, w800 h600
WB.Navigate("about:blank")
Loop
Sleep 10
Until (WB.readyState=4 && WB.document.readyState="complete" && !WB.busy)
WB.Document.Write(strHtml)
; WB.Document.Close()
WB.document.InvokeScript("displayDate")
; WB.document.parentWindow.document.InvokeScript("displayDate") ; does not work
return this
GuiClose:
ExitApp
}
}