Bug 138120

Summary: testcase - offsetWidth returns wrong value in the moment of the onload event when document is loaded in a frame
Product: [Applications] konqueror Reporter: Hatto Von Hatzfeld <hatto>
Component: khtmlAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: aiacovitti, finex, maksim
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description Hatto Von Hatzfeld 2006-11-29 23:59:43 UTC
Version:            (using KDE KDE 3.5.1)
Installed from:    SuSE RPMs
OS:                Linux

Using any of the properties
  document.body.offsetWidth
  window.innerWidth
  document.getElementsByTagName[0].offsetWidth
one always will get too small values (e.g. 76 instead of 1087) if (and only if!) the document is loaded into a frame (in the top window this problem does not occur, neither in Firefox).

Here is a test case:
http://www.salesianer.de/util/windowwidthframeset.html
Comment 1 Hatto Von Hatzfeld 2007-10-04 21:20:01 UTC
The problem occurs only WHILE the document is being loaded into the frame or when the onload event is being evaluated. Afterwards these properties show correct values.

This is a real problem for web designers who want to adjust their pages to the window with using Javascript.
Comment 2 Hatto Von Hatzfeld 2007-10-29 22:16:28 UTC
Now I have improved the test case. You can see that an additional resize event is been fired, although this "resizing" is caused only by the rendering process.

I still do not see any reason why in this case there is a difference between frames and top windows.
Comment 3 Maksim Orlovich 2007-10-29 22:19:59 UTC
Well, the frame gets loaded and then positionned, etc. Perhaps we're resizing it twice or something
Comment 4 Hatto Von Hatzfeld 2007-10-29 22:53:40 UTC
I think the simplest solution would be to delay the onload event until the last change (to size and/or position) has been made. It seems to me that other browsers (e.g. Firefox) do it that way.
Comment 5 Maksim Orlovich 2007-10-29 23:20:50 UTC
Perhaps. Unfortunately nothing related to the load event is simple... Also, imagine if the frame is with display:none. It should be loaded, no? 
(KHTML currently messes that up for iframes, but I have a mega-patch to fix it, which is tricky due to 4.0 stabilization period..)
Comment 6 FiNeX 2008-04-21 00:16:52 UTC
I've just tried the testcase with konqueror trunk. when the page is loaded the width values on both frames are the same. If I click to one of the two "Test this page in a frameset" when the page is re-loaded the first value is smaller (on that frame).
Comment 7 Andrea Iacovitti 2013-11-30 19:40:17 UTC
It seems fixed now (tested with KDE 4.11.4)