call javascript function question

133 views
Skip to first unread message

VdW

unread,
Mar 8, 2008, 1:38:01 PM3/8/08
to Google Web Toolkit
Hi,

I'm getting crazy, could somebody help me? I'm trying to call a
javascript function from GWT that is defined in an html page I load in
a Frame. Is that possible? When I call the function ($wnd.myFunction)
from my EntryPoint with JSNI I get an exception stating that the
function doesn't exist. Which seems logical since it is in the
specific html page.

But how am I supposed to do thsi??

Vincent

Carl Scott

unread,
Mar 8, 2008, 11:45:38 PM3/8/08
to Google Web Toolkit
You probably need to reference the said frame by name, then call your
javascript function. Good luck!

--
Carl Scott
Software Developer, Solertium Corporation

Hiedi

unread,
Mar 9, 2008, 10:00:37 AM3/9/08
to Google Web Toolkit

You could also try parent.myFunction or $wnd.parent.myFunction

VdW

unread,
Mar 10, 2008, 9:50:13 AM3/10/08
to Google Web Toolkit
Ok, now I'm getting somewhere: I can call the function by using
$wnd.frames[frameName].myFunction when I use a NamedFrame in GWT.
However I have to add the NamedFrame directly to the RootPanel. When I
put a Layout on the RootPanel and put the Frame in a ContentPanel in
the Layout it doensn't work.

What am I missing here?

Vincent
> > Vincent- Hide quoted text -
>
> - Show quoted text -

Carl Scott

unread,
Mar 10, 2008, 10:18:23 AM3/10/08
to Google Web Toolkit
Hmm, well it may not like that you're not using a ViewPort. Other
than that, you could try using a regular GWT widget instead (you don't
need to use ContentPanels unless layout is an issue for it or it's
child widgets, which probably is not for this Frame). That failing,
use Firefox or a debugging toolkit to inspect the DOM to find exactly
where this frame ends up. Maybe it's not getting added properly, or
maybe it's buried a level above or below where you're calling it
from. Once you can see the DOM, you can easily point your call in the
right direction.

Otherwise, if you have access to the source, I would add a line like
so to the page in the frame:

window.[parent/top/yourchoice].thefunction = functionyourecalling;
(parent probably works best but top could work too)

So that you can just say $wnd.thefunction (via JSNI) to call that
function from anywhere, without having to know anything about the DOM
layout.

Good luck!

--
Carl Scott
Software Developer, Solertium Corporation

> > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages