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