My favorites | Sign in
GWT
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 1720: Iframe onload event does not fire on Internet Explorer
40 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  pdr@google.com
Closed:  Jun 2011
Cc:  cramsdale@google.com


Sign in to add a comment
 
Reported by antongiu...@gmail.com, Oct 3, 2007
Found in GWT Release: 1.4.60 linux

Detailed description:
I create a named iframe, and I want it to handle onLoad events, so in
my constructor I add:

   sinkEvents(Event.ONLOAD);

then later in my application I implement:

   public void onBrowserEvent(Event event)
   {
      Window.alert("Browser Evernt: "+DOM.eventGetTypeString(event));
   }

ONLOAD events are fired on Safari and Mozilla, but the event is not
fired on IE.

Workaround if you have one:
look at first link below (only for gwt version 1.2.*)

Links to the relevant GWT Developer Forum posts:

this link is a workaround for gwt version 1.2.* but not for last version
(pls look at "jdc" post) :
http://groups.google.it/group/Google-Web-Toolkit/browse_thread/thread/8b007c96c0d6e8b2

a my post where I try to apply link above solution:
http://groups.google.it/group/Google-Web-Toolkit/browse_thread/thread/12e98f92243bc94f

my post where I ask help for generic problem:
http://groups.google.it/group/Google-Web-Toolkit/browse_thread/thread/1d0e7863bf02e8a9

Oct 5, 2007
#1 antongiu...@gmail.com
trick works in 1.4.60 too.

Problem seems to be here:

<!-- IE6 iframe name/load bug fork -->
        <replace-with class="org.myapp.client.BrowserFrameImplIE6">
        <when-type-is class="org.myapp.client.BrowserFrameImpl"/>
        <when-property-is name="user.agent" value="ie6"/>
        </replace-with>

compiler seems not compile "discriminant" for ie6 (though no errors are returned),
and when I run it on ie6/7 it uses again BrowserFrameImpl and not BrowserFrameImplIE6
class.
Oct 21, 2008
#2 br...@google.com
(No comment was entered for this change.)
Labels: -priority-medium
Sep 19, 2009
#3 zmeuld...@gmail.com
This issue can be easily fixed in the GWT code by using attachEvent and a special
dispatchEvent function:

// GWT 1.7.0
// com.google.gwt.user.client.impl.DOMImplTrident#initEventSystem()
@com.google.gwt.user.client.impl.DOMImplTrident::dispatchEventProxy = function() {
 
@com.google.gwt.user.client.impl.DOMImplTrident::dispatchEvent.call($wnd.event.srcElement);
}

// GWT 1.7.0
// com.google.gwt.user.client.impl.DOMImplTrident#sinkEventsImpl(Element, int)
if (chMask & 0x08000) {
  if (bits & 0x08000) {
    elem.attachEvent('onload',
@com.google.gwt.user.client.impl.DOMImplTrident::dispatchEventProxy);
  } else {
    elem.detachEvent('onload',
@com.google.gwt.user.client.impl.DOMImplTrident::dispatchEventProxy);
  }
}

It's a pity this issue hasn't been fixed in 2 years.
Oct 20, 2009
#4 dun7...@gmail.com
@zmeuldumy
Is this patch still working with the last trunk version ? I'am trying to compile it but 
I've got compile errors.
Would be great if it could be solved natively.
Dun
Oct 29, 2009
#5 shining...@gmail.com
@dun74fr

See the attachment.
You can use it directly in your project and gwt will be overridden automatically
(because your java code precedes gwt jar).
DOMImplTrident.java
10.0 KB   View   Download
Oct 30, 2009
#6 dun7...@gmail.com
@shining365
Thank you
Nov 16, 2009
#7 roa...@googlemail.com
The patch above by shining365 only works for the recent 1.7 release. I can't update
my GWT version at the moment. I am stuck with 1.5.3. Does a patch for 1.5.3 exist? I
would be really happy about one.
Dec 21, 2009
#8 cramsdale@google.com
Closing as a result of issue triage. More information can be found here:

http://groups.google.com/group/google-web-
toolkit/browse_thread/thread/3a7bf1c6a3d35431

Thanks
Status: AssumedStale
Dec 21, 2009
#9 cramsdale@google.com
(No comment was entered for this change.)
Cc: cramsd...@google.com
Jan 6, 2010
#10 tdzierz...@gmail.com
Hi

Problem still exists in GWT 2.0 (ie8 browser and probably older versions), 
as an example:

public class GWTIEOnLoadTest implements EntryPoint {

    public void onModuleLoad() {
        Frame frame = new Frame() {
            @Override
            public void onBrowserEvent(Event event) {
                if (event.getTypeInt() == Event.ONLOAD) {
                    Window.alert("ONLOAD");
                }
                super.onBrowserEvent(event);
            }
        };

        frame.setHeight("100px");
        frame.setWidth("100px");
        frame.sinkEvents(Event.ONLOAD);

        frame.setUrl("about:blank");

        RootPanel.get().add(frame);

    }
} 

In IE we'll never see dialog with "ONLOAD".

Full test in attachment.
GWTIEOnLoadTest.zip
29.4 KB   Download
Mar 8, 2010
#11 gfo...@gmail.com
Hey!

Here is the patch modified for GWT 2.0.

We'd love to see this issue solved formally tho.

-fotos
DOMImplTrident.java
1.5 KB   View   Download
Mar 30, 2010
#12 cramsdale@google.com
Reopening as issue still exists, and gfotos was kind enough to supply a patch.
Status: New
Apr 22, 2010
#14 jgon...@gmail.com
Hi
 
A more slick way to attach a dom handler for (browser) onload events without manually
sinking LoadEvent and overriding onBrowserEvent is by executing addDomHandler on
Frame creation like this:

Frame frame = new Frame() {
    {
        addDomHandler(new LoadHandler() {
           @Override
           public void onLoad(LoadEvent event) {
               Window.alert("ONLOAD");
           }
        }, LoadEvent.getType());
    }
};

This way all the (relevant) code is in one place.

Note that this doesn't fix the bug in IE, and it's just another workaround / solution
for catching the native onload events in iframes.
Jun 15, 2010
#15 frank.co...@gmail.com
I'm using GWT 2.0.3 and I'm having the same problem on IE8 where I'm using a Frame to load some applet. I really need a working ONLOAD event handler as I have to wait until the new page is loaded within this Frame before visualizing it. Else the JRE might still activate the previous applet which is kind of a mess. Could someone fix this asap?
Oct 13, 2010
#16 Had...@gmail.com
Getting into that GWT native code looks interesting but too time-consuming for such a tiny reward. I'm sure Google's working on this. It's been a GWT issue for over three years now.

If you don't want to mess with class-replacement (which entails, among other error-prone maintenance chores, keeping track of what you've overridden so that you don't accidentally replace new code with old code), something like this might work as a stopgap measure.

private native boolean initOnLoadHandling(Element element) /*-{
		var function = this.@com.my.package.YourClass::onLoad();
		if(element.addEventListener) {
			element.addEventListener("load", function, false);
			return true;
		} else if (element.attachEvent) {
			var r = element.attachEvent("onload", function);
			return true;
		} else {
			return false;
		}
}-*/;

This, in conjunction with an onLoad() java method in YourClass.
Oct 26, 2010
#17 ambr...@gmail.com
This appears to be broken still in GWT 2.1 RC1.  The previous patch that has been updated for GWT 2.0.x doesn't not work as there have been several changes to the patched class in GWT 2.1.


Nov 18, 2010
#18 rjrjr@google.com
(No comment was entered for this change.)
Status: Accepted
Labels: Milestone-2_2
Nov 29, 2010
#19 connect....@gmail.com
not working on IE 7&8


Jan 12, 2011
#20 rjrjr@google.com
We should really fix this. Phil, think you can get it in?
Owner: p...@google.com
Jan 13, 2011
#21 rjrjr@google.com
(No comment was entered for this change.)
Labels: Milestone-2_3
Jan 13, 2011
#22 rjrjr@google.com
(No comment was entered for this change.)
Labels: -Milestone-2_2
Jan 20, 2011
Project Member #24 pdr@google.com
Not quite yet--had to roll back that change. But soon it will be fixed :)
Feb 9, 2011
#25 gfo...@gmail.com
Hello again,

since we upgraded to GWT 2.1 I decided to have another look at this issue.

@pdr perhaps the test failed because in your changeset (r9567) you removed the callDispatchUnhandledEvent, which is required by Image load (see r7092).

I attach two patches:
1. For trunk, where the fix is properly integrated in GWT. This definitely needs review and perhaps more (or better) tests.
2. The smallest possible hack-patch for DOMImplTrident.java, like the one I have provided for GWT 2.0, which you can use by overriding the GWT DOMImplTrident class in your classpath (project classes always take precedence), for those of who can't wait for a GWT release. This patch doesn't break image onload.

Both of the patches work correcly (have been verified in IE and other browsers) and fire events for Image and Frame onload events. The trunk patch also passes all tests (new and old).

Lets close this issue once and for all (and a proper backport to 2.1.x is mostly welcomed)!

-fotos

PS. Review the trunk patch here: http://gwt-code-reviews.appspot.com/1353801
FrameOnLoad.patch
12.2 KB   View   Download
DOMImplTrident.java-2.1.patch
1.9 KB   View   Download
Mar 9, 2011
#26 wgla...@gmail.com
Is there any progress oin this issue, is there a known workaround for gwt-2.2 ?

  Best regards, Wolfgang
Mar 17, 2011
Project Member #27 pdr@google.com
Fixed in: http://gwt-code-reviews.appspot.com/1294801
Status: FixedNotReleased
Jun 17, 2011
Project Member #28 mrrussell@google.com
(No comment was entered for this change.)
Status: Fixed
Jul 13, 2011
Project Member #30 pdr@google.com
I fixed this a long time ago and I think it was released in 2.3. If not, the fix will be released with GWT 2.4 (which should be released very soon).
Jul 13, 2011
#31 gfo...@gmail.com
The fix is indeed included in GWT 2.3.0 as you can see at the milestone attribute of this issue, as well as the source code of 2.3.0-rc tag at https://code.google.com/p/google-web-toolkit/source/list?path=/tags/2.3.0-rc1/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java&start=10074

The fix was actually merged in GWT 2.3 branch at r9874. It should also work with GWT 2.4 and any later releases. If you have any frame loading issues please open a new issue! Now we should all leave this issue rest in eternal peace.
Jul 18, 2011
#32 elloalis...@gmail.com
I've upgraded my gwt to 2.3.0 version just to get this fix, but I still doesn't get sucess using onLoad in Frame object.

Should I do something to run this fix? I need to get this event because I'm using a loading mask for the iFrame and I need to hide this when the content of the frame loaded.

Is there a workaround to get this event?
Jul 18, 2011
Project Member #33 pdr@google.com
elloalis..., do you mind comparing your code with the testOnLoadEventFiresWithDomLoadHandler() test here: https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/dom/client/FrameTests.java

If your code is following a similar pattern and is still failing, can you provide some more details? (Code snippet, IE version, etc).
Jul 18, 2011
#34 elloalis...@gmail.com

It works when I try to load e.g. http://www.google.com.br , but I need to load a URL something like https://www.example.com/example.pdf and it doesn't work well. I'm using IE7 and below my code:

Frame frame = new Frame("https://www.example.com.br/example.pdf") {{
   addDomHandler(new LoadHandler() {
      public void onLoad(LoadEvent event) {
         loadingMask.setVisible(false);
      }
   }, LoadEvent.getType());
}};
Jul 18, 2011
Project Member #35 pdr@google.com
Is the problem triggered when you're loading a secure frame in an insecure page? Or is the problem triggered when loading a pdf in an iframe?
Jul 18, 2011
#36 elloalis...@gmail.com
This problem is triggered when I load a PDF in an iframe
Jul 18, 2011
#37 fabio.wq
Have you tried to use a mix solution (java script + GWT).

Yes, It is not a good approach.
Jul 18, 2011
Project Member #38 pdr@google.com
It looks like there may be an issue with PDFs in iFrames in IE7: http://frank.vanpuffelen.net/2007/03/iframeonload-doesnt-fire-for-activex.html

I haven't tested it myself, but there is a workaround posted in the comments of that link dealing with checking onreadystatechange. This feels like a separate issue from this bug; do you mind creating a new bug for onload events with PDF pages in IE7?
Jul 18, 2011
Project Member #40 pdr@google.com
Please file a new bug/issue here: https://code.google.com/p/google-web-toolkit/issues/entry
Jul 18, 2011
#41 elloalis...@gmail.com
But IE works well when we catch the iframe readyState. Is there a way to get this iframe property with GWT?

We tried using a mix solution (like fabio.wq has suggested), but it was not a good idea because FF works with onLoad event and IE works with readyState. The maintance would be terrible and we had problem when we had more than 1 iframe in the project.

Hope somebody has a solution to share with us.
Sign in to add a comment

Powered by Google Project Hosting