My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
  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
Closed:  Jun 2011

Sign in to add a comment
Reported by, 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:


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) :

a my post where I try to apply link above solution:

my post where I ask help for generic problem:

Oct 5, 2007
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"/>

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
Oct 21, 2008
(No comment was entered for this change.)
Labels: -priority-medium
Sep 19, 2009
This issue can be easily fixed in the GWT code by using attachEvent and a special
dispatchEvent function:

// GWT 1.7.0
// = function() {$wnd.event.srcElement);

// GWT 1.7.0
//, int)
if (chMask & 0x08000) {
  if (bits & 0x08000) {
  } else {

It's a pity this issue hasn't been fixed in 2 years.
Oct 20, 2009
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.
Oct 29, 2009

See the attachment.
You can use it directly in your project and gwt will be overridden automatically
(because your java code precedes gwt jar).
10.0 KB   View   Download
Oct 30, 2009
Thank you
Nov 16, 2009
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
Closing as a result of issue triage. More information can be found here:

Status: AssumedStale
Dec 21, 2009
(No comment was entered for this change.)
Jan 6, 2010

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() {
            public void onBrowserEvent(Event event) {
                if (event.getTypeInt() == Event.ONLOAD) {





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

Full test in attachment.
29.4 KB   Download
Mar 8, 2010

Here is the patch modified for GWT 2.0.

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

1.5 KB   View   Download
Mar 30, 2010
Reopening as issue still exists, and gfotos was kind enough to supply a patch.
Status: New
Apr 22, 2010
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() {
           public void onLoad(LoadEvent event) {
        }, 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
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
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 =;
		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
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
(No comment was entered for this change.)
Status: Accepted
Labels: Milestone-2_2
Nov 29, 2010
not working on IE 7&8

Jan 12, 2011
We should really fix this. Phil, think you can get it in?
Jan 13, 2011
(No comment was entered for this change.)
Labels: Milestone-2_3
Jan 13, 2011
(No comment was entered for this change.)
Labels: -Milestone-2_2
Jan 20, 2011
Project Member #24
Not quite yet--had to roll back that change. But soon it will be fixed :)
Feb 9, 2011
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, 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)!


PS. Review the trunk patch here:
12.2 KB   View   Download
1.9 KB   View   Download
Mar 9, 2011
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
Fixed in:
Status: FixedNotReleased
Jun 17, 2011
Project Member #28
(No comment was entered for this change.)
Status: Fixed
Jul 13, 2011
Project Member #30
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
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

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
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
elloalis..., do you mind comparing your code with the testOnLoadEventFiresWithDomLoadHandler() test here:

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

It works when I try to load e.g. , but I need to load a URL something like and it doesn't work well. I'm using IE7 and below my code:

Frame frame = new Frame("") {{
   addDomHandler(new LoadHandler() {
      public void onLoad(LoadEvent event) {
   }, LoadEvent.getType());
Jul 18, 2011
Project Member #35
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
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
It looks like there may be an issue with PDFs in iFrames in IE7:

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
Please file a new bug/issue here:
Jul 18, 2011
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