Closed Bug 79475 Opened 23 years ago Closed 20 years ago

resizeTo() and moveTo() resize iframe's parent window.

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: jeffrey.phillips, Assigned: jst)

Details

(Keywords: testcase, Whiteboard: [good first bug])

Attachments

(3 files)

resizeTo or moveTo javascript functions are invoked on an iframe's parent window
instead of the iframe window object itself. Steps to reproduce:

1. Create main.html with the following text:

<html>
<head><title>Main Page</title></head>
<body>
    <p>Test of resizeTo and moveTo in an iframe:</p>
    <p><iframe src="iframe-test.html" width="200" height="200"></iframe></p>
</body>
</html>

2. Create iframe-test.html with the following text:
<html>
<head>
<script language="javascript"> <!--
    
    // Test to make sure this and this.parent are not the same.
    // If they are the same then we are probably not an iframe
    // inside a window.
    if (this != this.parent) {

        // Will affect parent frame not the iframe, but should.
        this.resizeTo(10,10);
        this.moveTo(0,0);
    } else document.write("You're not in an iframe!");
//--></script>
</head>
<body>
    <p>In da iframe.</p>
</body>
</html>

3. Open main.html and the whole window will be resized and moved instead of just
the iframe.

Have tried this with many different ways of getting the iframe window object and
all result in the same behavior (viz- document.__parent__.resizeTo,
document.getElementById("myIframe").resizeTo, etc.)
Cannot find any specific examples at this time, but this was noticed because an
iframe banner ad resized my browser window.
over to DOM0.
Assignee: pollmann → jst
Status: UNCONFIRMED → NEW
Component: HTMLFrames → DOM Level 0
Ever confirmed: true
QA Contact: amar → desale
What does IE do if you call resizeTo() in an iframe?
In IE, both resizeTo and moveTo will affect the IFRAME object and not any of the
parent or child frames.
Targetting for mozilla1.0
OS: Windows 2000 → All
Hardware: PC → All
Target Milestone: --- → mozilla1.0
Bugs targeted at mozilla1.0 without the mozilla1.0 keyword moved to mozilla1.0.1 
(you can query for this string to delete spam or retrieve the list of bugs I've 
moved)
Target Milestone: mozilla1.0 → mozilla1.0.1
SEVERITY = LOW [(1)No Crash, (2)functional failure, (3)No Cosmetic failure]
VISIBILITY = HIGH [(1)Reporter says that he noticed this bug when iframe banner 
ad resized his browser window, which means real website usage is high. (2)Gets 
one point of compatibility with other browsers since it works very well on IE. 
(3)Gets one more point on compliance with adopted techonology which  is JS] 

PRIORITY = VISIBILITY * SEVERITY

Hence Priority = p3

adding word "qawanted" because I'm setting this priority on available data & if 
someone feels otherwise then please investigate this more & feel free to change 
this priority.
Keywords: qawanted
Priority: -- → P3
Target Milestone: mozilla1.0.1 → ---
This seems to have been outstanding for a long time and is not fixed in Netscape
7. There is a workaround that seems to work but is a bit messy and obviously a
full implementation would be best:-

var w = 50;
var h = 100;
if (document.all)
   resizeTo(w,h)
else
{
   var fname = this.name;
   if (fname != "")
   {
      parent.document.getElementById(fname).width = w;
      parent.document.getElementById(fname).height = h;
   }
}
The problem with this is that you must name the IFRAME in the parent document,
and you have to allow for IE browsers as unless your IFRAME document is coming
from the same server you cannot change the properties of the IFRAME in IE.
ResizeTo will always work in IE. See www.dpnsoftware.net for demo.
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
The bug also happens when trying to resize a XUL iframe in a XUL window. The
warkaround proposed in #8 does not work (re-assigning the height/width
properties of the XULElement/HTMLElement seems not to be taken into account).
Attached file Testcase for bug 79475
This testcase shows that calling iframe.contentWindow.resizeTo() inside the
parent window or window.resizeTo() inside the iframe resizes the parent window,
not the iframe.
Keywords: qawantedtestcase
So the problem is that the window object page scripts see _is_ an iframe,
effectively.  Hence to get the desired behavior for scripts we map
resizeto/moveto calls on any window to the root window...
Does IE behave the same way for <frame> and <iframe>?
Another example (IFrame Code)

<html><head></head><body onLoad=\"javascript:self.resizeTo(0,0);\"></body></html>
This has been fixed for a month for resizeTo (see bug 248870).  jst, mind fixing
moveTo as well?
Whiteboard: [good first bug]
All this really needs is an IsFrame() check in nsGlobalWindow::MoveTo, like
nsGlobalWindow::ResizeTo has.
Seems like sizeToContent() needs this check too, so I added that while I was at
it.
Attachment #170584 - Flags: superreview?(bzbarsky)
Attachment #170584 - Flags: review?(bzbarsky)
Comment on attachment 170584 [details] [diff] [review]
Fix per bz's suggestion.

Looks good. r+sr=bzbarsky
Attachment #170584 - Flags: superreview?(bzbarsky)
Attachment #170584 - Flags: superreview+
Attachment #170584 - Flags: review?(bzbarsky)
Attachment #170584 - Flags: review+
Assignee: general → jst
Fixed.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: