Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Fri, 2 Nov 2007 01:11:58 -0700,    group: microsoft.public.inetsdk.programming.webbrowser_ctl        back       


From VB6 code - run Javascript function in WebBrowser control   
Hi,

Can this be done?   Can VB6 code execute a javascript function in a loaded page 
of a webbrowser control?

I have a VB6 project with a WebBrowser control on it with this page loaded.

--------------------------------------
<html>
<body>
  <script>
   function showalert(){
    alert("Hello World");
   }
  </script>
  <p>my web page</p>
  <input type="button" onclick="showalert()" value="Click for Hello World">
</body>
</html>
--------------------------------------

In a cmdButton_Click() event I'd like to call the javascript function 
showalert().


Thanks
Ken
date: Fri, 2 Nov 2007 01:11:58 -0700   author:   kjm2

Re: From VB6 code - run Javascript function in WebBrowser control   
"kjm2"  wrote in message
news:YYAWi.1227$Tp3.832@newsfe15.lga
> Can this be done?   Can VB6 code execute a javascript function in a
> loaded page of a webbrowser control?

window.execScript
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Fri, 2 Nov 2007 08:12:02 -0400   author:   Igor Tandetnik

Re: From VB6 code - run Javascript function in WebBrowser control   
Thanks for the reply but after doing a bunch of searching on the web for 
window.execScript I don't think that is what I need.  That will execute the 
script I pass it but what Iwant to do is to execute an existing script/function 
that is loaded in a BrowserControl.

Something like:   WebBrowser.Document.??? where I can run the existing fuction 
in a javascript function loaded in the current browser control's loaded page.

Thanks
Ken



"Igor Tandetnik"  wrote in message 
news:ejsLMoUHIHA.2480@TK2MSFTNGP05.phx.gbl...
> "kjm2"  wrote in message
> news:YYAWi.1227$Tp3.832@newsfe15.lga
>> Can this be done?   Can VB6 code execute a javascript function in a
>> loaded page of a webbrowser control?
>
> window.execScript
> -- 
> With best wishes,
>    Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not necessarily a 
> good idea. It is hard to be sure where they are going to land, and it could be 
> dangerous sitting under them as they fly overhead. -- RFC 1925
>
date: Fri, 2 Nov 2007 11:52:33 -0700   author:   kjm2

Re: From VB6 code - run Javascript function in WebBrowser control   
kjm2  wrote:
> Thanks for the reply but after doing a bunch of searching on the web
> for window.execScript I don't think that is what I need.  That will
> execute the script I pass it but what Iwant to do is to execute an
> existing script/function that is loaded in a BrowserControl.

You can pass a script fragment that consists of a function call:

window.execScript("myFunction();", "JavaScript")

> Something like:   WebBrowser.Document.??? where I can run the
> existing fuction in a javascript function loaded in the current
> browser control's loaded page.

WebBrowser.Document.parentWindow.execScript(...)

You should also be able to call the function via late binding, but I'm 
not exactly sure how to express this in VB. Try this:

Dim w as Object
Set w = WebBrowser.Document.parentWindow
w.myFunction ' myFunction is the name of the function in the script

-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Fri, 2 Nov 2007 16:07:56 -0400   author:   Igor Tandetnik

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us