Access JavaApplet through DOM

B

BJ

Hi,

I am running a JavaApplet call ViewOne ro on my web page. The
documentation states I can execute methods of that applet by accessing
the objectname.methodname:

i.e. v1Pro.ZoomIn()

I am hosting the applet in a webbrowser control on a desk top
application. I can access the Parent object but how do I access the
child object (applet)?

J
 
B

BJ

THE ANSWER:

Ok so I was having a conversation with another programmer in the
office. I told him I knew how to execute a JavaScript function on a
web page hosted by IE's Web Browser control (shdocvw.dll), but I
didn't know how to access a child object on the page. My desktop
application is using this control to host a web page that contains a
JavaApplet. The JavaApplet exposes functions that can be executed by
JavaScript. For example, I can place the following code in the click
event of a button to zoom in on the image:

document.viewOne.zoomIn();

document is just that the parent object. viewOne is the child object
on the page which in this case is the ViewOne Pro Java Applet.
Finally, zoomIn() is a function of the applet that is exposed to
JavaScript. The goofy way to implement this would be to wrap the line
above in a Javascript function (ZoomDaPage) which I could later
execute with the line below:

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

Then it hit me. Wait whit don't I just execute an inline / no name /
self executing function? Below is the answer:

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

JavaScript Inline functions will allow me complete control of a
rendered web page within my Web Browser object.

Now, you may have caught on that this is a VB6 desktop application but
my original question as about JavaScript. Trust me, this group would
have had a better shot at the answer than the legacy VB group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top