Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Execute JavaScript in a Web Browser Control using VB6
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Julie  
View profile  
 More options Dec 9 2007, 10:48 pm
Newsgroups: microsoft.public.vb.general.discussion
From: Julie <julie6232...@yahoo.com>
Date: Sun, 9 Dec 2007 19:48:37 -0800 (PST)
Local: Sun, Dec 9 2007 10:48 pm
Subject: Execute JavaScript in a Web Browser Control using VB6
I was searching the new groups trying to find an answer to the
question, how do I access a child object of a webpage hosted in a Web
Browser Control (shdocvw.dll)?  The JavaScript group gave me the most
grief and least amount of actual help.

What I was trying to accomplish was the executing of a function
exposed by a JavaApplet using JavaScript.  A company called Deaja has
a product call ViewOne Pro.  ViewOne Pro is a JavaApplet that will
allow 300 different file types to rendered (pdf, FileNet TIFF's,
etc).  For example, a web page that contains this applet can place
code behind the click event of a button that will allow the user to
zoom in on an image:

document.viewOne.zoomIn();

My question was how do I execute this line of code in VB6 using the
Web Browser control?  Using the line below, I could execute a
JavaScript function which would serve as a wrapper to the line above:

Me.wbImageViewer.Document.parentWindow.execScript "MyWrapperFunc();",
"JScript"

That would work, but seem kluge and the web page developer would have
to develop a function on the page for each function I wanted to
perform.  First of all, my application wasn't the only one using this
page and it made for a thicker client.  Then it hit me.  If I could
execute a JavaScript function, why not create an inline / no name /
self executing function?

Me.wbImageViewer.Document.parentWindow.execScript "(function()
{document.ViewONE.zoomIn();}());", "JScript"

Freakin awesome!!!  Now I do not have to rely on the web page owner to
implement JavaScript wrapper functions just for me and since this code
is not stored on the page after execution, the page remains thin and
clean.  I want to say it even offers a layer of security because the
code doesn't stay on the page available to the pages source.  I can
even create a function that takes parameters:

Me.wbImageViewer.Document.parentWindow.execScript "(function(parmName)
{document.ViewONE.getPage(parmName);}('36'));", "JScript"

I'm posting this solution primarily because it took me a while to come
up with an answer and in the event someone else needed this solution
(you can still host a Web Browser control in a .Net Win Form
application), here is the answer.  Sharing is a wonderful thing :-)

Cheers,

J


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »