Jump to content

Execute a web page's javascript


ivan
 Share

Recommended Posts

Oops. Forgot the first paragraph.

I've seen a good dozen times in the help and support forum people asking how to execute javascript functions in a web page. I've already done this using htas, but never really managed to solve in plain html.

The example should illustrate the HOW.

The one thing that I've not been able to do is to get the return values or objects from functions, only through htas as shown in Dynamic html in au3, manipulate javascript objects in au3

#include <IE.au3>

$Html = '<html>' & @CRLF _
        &'<head>' & @CRLF _
        &'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">' & @CRLF _
        &'<title></title>' & @CRLF _
        &'<meta name="description" content="">' & @CRLF _
        &'<meta name="keywords" content="">' & @CRLF _
        &'<meta name="author" content="iperezm@interactive.net.ec">' & @CRLF _
        &'<meta name="generator" content="AceHTML 5 Freeware">' & @CRLF _
        &'<script type=text/javascript>' & @CRLF _
        &'function JsMsgBox(pMsg){' & @CRLF _
        &'alert(pMsg);' & @CRLF _
        &'}' & @CRLF _
        &'</script>' & @CRLF _
        &'</head>' & @CRLF _
        &'<body>' & @CRLF _
        &'Time to get som..' & @CRLF _
        &'</body>' & @CRLF _
        &'</html>'
$oIE=_IECreate()
_IEDocWriteHTML ( $oIE, $Html )
$oIE.document.parentwindow.execScript('JsMsgBox("beer");', 'javascript')
Edited by ivan
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...