How do I access the child object?

J

Julie

Hi,

I am running a JavaApplet call ViewOne Pro 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
 
D

Doug Miller

Hi,

I am running a JavaApplet call ViewOne Pro on my web page.

Java and JavaScript ain't the same thing.

comp.lang.java is over that way -------------------->.
 
K

Kailash Nadh

Hi,

I am running a JavaApplet call ViewOne Pro 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

Are you trying to access the child object inside your Java Applet,
using Javascript in the webpage? If yes, it is not possible.
Javascript and Java are two entirely different languages.
 
T

Thomas 'PointedEars' Lahn

Julie said:
I am running a JavaApplet call ViewOne Pro 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)?

According to the documentation, the method identifier is zoomIn().
Both Java and ECMAScript implementations are case-sensitive.


HTH

PointedEars
 
J

Julie

According to the documentation, the method identifier is zoomIn().
Both Java and ECMAScript implementations are case-sensitive.

HTH


HTH: "According to the documentation, the method identifier is
zoomIn(). Both Java and ECMAScript implementations are case-
sensitive."

Thank you. You are absolutly correct. It actually is wrong in my
code and I will make the change. Also thank you for recognizing that
I can access the exposed methods of the Java Applet through
JavaScript.

If I were to to write the line that contained the zoomIn() function,
what would the entire line look like?

The error message I am getting says v1Pro is unrecognized. I just
need to know the fully qualified JavaScript line to access the object.

J
 
T

Thomas 'PointedEars' Lahn

Actually, the method identifier is `zoomIn'. (I have only gotten into the
habit of denoting methods in prose by appending a pair of parentheses :))
HTH: "According to the documentation, the method identifier is
zoomIn(). Both Java and ECMAScript implementations are case-
sensitive."

Google Groups quotes the message that you are replying to automatically for
you. You are to walk through the automatically included quotation from top
to bottom, to trim the parts that you do not refer to, and to reply below
each part that you do refer to. (Unfortunately, it promotes full-quoting
because it does not put the text cursor at the top. But it is likely that
the rationale for this was not to promote top-posting which is even more
offending in Usenet.)

It also includes an attribution line above the quotation so that one can see
at a glance who is responsible for the quoted text. Please do not remove
that manually.

That said, you should not use Google Groups for posting to Usenet (it is
good for read-only access, though); use a locally installed newsreader
application instead. I can recommend Mozilla Thunderbird for Windows and
KNode for GNU/Linux.
[...]
If I were to to write the line that contained the zoomIn() function,
what would the entire line look like?

The error message I am getting says v1Pro is unrecognized. I just
need to know the fully qualified JavaScript line to access the object.

Probably you will need to show the relevant code or post a URL for it.

If I were to make an educated guess though, I would assume that what you
call "object name" here is in fact the value of the `id' attribute of the
`applet' or `object' element in your markup. AFAIK, only the MSHTML DOM
makes that available as a property of a host object in the scope chain.
Therefore, you would retrieve the reference instead with

var foo;

// W3C DOM
if (/\b(function|object)\b/i.test(typeof document.getElementById)
&& document.getElementById)
{
foo = document.getElementById("v1Pro");
}

// IE4 DOM
else if (typeof document.all == "object")
{
foo = document.all("v1Pro");
}

(See <also http://PointedEars.de/scripts/dhtml.js>.)

And then use at least

if (foo)
{
foo.zoomIn(...);
}

where the ellipsis denotes the comma-separated list of parameters that you
need to pass to the applet's method, if any.


PointedEars
 
J

Julie

The command in JavaScript is

document.viewONE.zoomIn();

But I'm not access this applet in JavaScript on a web page. I am
executing this line on a page being hosted in a webbrowser control.
The error I am receiving is object not valid.

Currently, I can successfully call / execute a JavaScript function on
the page using a very similar command listed below:

doc.parentWindow.execScript('alert("hello");', 'JavaScript');

The following line does not work

doc.parentWindow.execScript('document.viewONE.zoomIn();',
'JavaScript');

I need to access not the parent node but the child node used to
represent the child node viewONE

I was hopeing someone would help me access a method of a child node:

doc.parentWindow.childnode(getElementById("viewONE")).zoomin

Even though this is a JavaScript form / blog / group and my code is
utilizing a webbrowser control with in a desktop application, deriving
the proper format to involke a method shouldn't be too different. One
solution that will work is to wrap the document.viewONE.zoomIn(); as
part of a user defined Javascript function.

<script type="text/javascript">
function zoomInOnImage()
{
document.viewONE.zoomInOnImage();
}
</script>

and then call zoomIt in the webbrowser control code behind:

doc.parentWindow.execScript('zoomInOnImage();', 'JavaScript');

The problem I'm having with this solution is that it is ... clugie for
lack of a better term.

J
 
T

Thomas 'PointedEars' Lahn

Julie said:
The command in JavaScript is

document.viewONE.zoomIn();

Are you referring to something? Please reply below trimmed quotes, that
is, leave in the parts you are referring to (as I have explained before)
But I'm not access this applet in JavaScript on a web page. I am
executing this line on a page being hosted in a webbrowser control.

As you do not say which Webbrowser control and which version of it, the
statement is utterly useless. Suffice it to say that a Webbrowser control
should use a layout engine, most certainly a DOM, and probably the W3C DOM.
(That is the case with more recent versions of the MSHTML component.) So
you should at first try the solution that I have provided.
The error I am receiving is object not valid.

As you do not state the specifics of the error message (e.g. object
identifier, line number), and do not post all of the relevant code,
that statement is utterly useless.
[...]
I was hopeing someone would help me access a method of a child node:

doc.parentWindow.childnode(getElementById("viewONE")).zoomin

And what would `doc', `doc.parentWindow', and `doc.parentWindow.childnode' be?


PointedEers
 
J

Julie

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, I want to say this thread has been helpful and gave me the answer
(one post did honestly try to help) but all I got was a lot of
criticism on posting etiquette. I usually try to read between the
lines to get the senders point, most the time there wasn't a point,
not a useful one anyway. I really didn't know how to better explain
my problem other than to state I wanted to access a child object of a
page using JavaScript. Even though the solution did so in a
roundabout way, it was the correct one. The ability to access the
exposed functions of a JavaApplet using JavaScript is new to some, so
I'm glad I was able to contribute something useful to the group.

Have a great day.
 

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

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top