another iframe
The setup is like this:
domain1/page1 has an iframe that loads domain2/page2
domain2/page2 has the GWT module.
In other words DOM looks like:
domain/page1
iframe (domain/page2)
iframe (gwt)
The module has the JSNI code that is intended to register a function
in page2 so other none-gwt components (again in page2) can use,
something like
$wnd.myfunc = function() {...}
And in my HTML, I do
<input type="button" onclick="myfunc()"></input>
I know it feels like I am trying to some cross site stuff between
page1 and page2, but I am not. Page1 is simply a wrapper for
displaying page2. All GWT and JSNI codes are intended to use within
Page2 alone. That's where I am having problem. I think because GWT
itself is in iframe and $wnd is intended to get top window, it works
in most cases when the host page is in the top window and on the same
domain. But my hostpage is an iframe and different domain.
Right now my workaround is to declare a new javascript object on
page2, like
var myfuncHelper = new Object();
then my JSNI looks like
$wnd.myfuncHelper.myfunc = function() {...}
and the onclick="myfuncHelper.myfunc()"
That works. I am wondering if there is better implementation though.
On Jun 22, 1:29 pm, Olivier Monaco <[email protected]> wrote:
> The iframe is the GWT iframe or another one? Do you have a usecase ?
>
> Olivier
>
> On 22 juin, 18:37, randasin <[email protected]> wrote:
>
> > I have some JSNI code that assign a function to a variable in the
> > window as suggested in JSNI document: Calling a Java Method from
> > Handwritten JAvascript (http://code.google.com/webtoolkit/doc/latest/
> > DevGuideCodingBasicsJSNI.html#calling)
>
> > The problem is if the JSNI code runs inside an iframe, then the
> > function is registered in the top window, and I get a Object expected
> > (or Object is null) script error on IE.
>
> > How could I make sure the function is registered in the iframe, and
> > not to the window?
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.