Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I trigger Javascript from VB?

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
GB
I've got a WebBrowser object in VB6 which contains an HTML document which in turn has a Javascript routine within it.

I'd like a line of VB code which will trigger the Javascript routine when a button is clicked in VB.

Something along the lines of:
WebBrowser1.Document.Scripts("JSRoutineName").Run

Is it possible?

Alternatively, if I place a link in the HTML document that triggers the javascript code, can I trigger the link from within VB?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
>WebBrowser1.Document.Scripts("JSRoutineName").Run
This instead.
[tt] WebBrowser1.Document.ParentWindow.ExecScript "JSRoutineName()","Javascript"[/tt]
In case you might have concern on threading, here is an alternative to use setTimeout.
[tt] WebBrowser1.Document.ParentWindow.setTimeout "JSRoutineName()", 0[/tt]
 
Great, thanks.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top