Closed Bug 269465 Opened 20 years ago Closed 20 years ago

window.open opens window with wrong dimensions

Categories

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

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: slabbi, Unassigned)

Details

Attachments

(3 files)

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a5) Gecko/20041112

Well, it has worked for years now but today I have recognized that Moz has some
problems with the correct window dimensions (I tested it with 1.8a4 which shows
the same bug).

On http://8bit-museum.de/docs/apple1.htm I try to open a new windows using

<a href="javascript:PopUp(0,'Steven Wozniak und Steve
Jobs','../imgs/apple/jobswozniakg.jpg',640,451);">

function PopUp(Ort, Title, Path, Width, Height) {
[...]
  theTitle = Title;
  theWidth = Width;
  theHeight = Height;

  var winFeatures =
'dependent=yes,locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,width='
+ Width + ',height=' + Height;
    popWin = window.open('toolshtml.htm', 'PopWin' + imgCount++, winFeatures);
  }

That created window width is fine, but the height is approx. 100 pixels too big.
This happens with all pictures on this site. I checked the values for
winFeatures before window.open is called and they are fine.

I use the same script on another site http://slabihoud.de/ to display pictures
and here it works fine?!?

There is another bug with deals with a javascript bug when window.open is called
but I did not find a bug according a wrong dimension of the created window.
doesn't block Mozilla development
Severity: blocker → normal
This has been reported on Windows builds before... the problem is that none of
the developers have been able to reproduce it, as I understand.
Whiteboard: DUPEME
I got the case with the following javascript function on Mozilla 1.7.3 (Win 98SE):

function MM_openBrWindow(theURL,winName,features) { 

  window.open(theURL,winName,features);
}

called by

<A HREF="#"
onClick="MM_openBrWindow('marcab.htm','CABAL','width=480,height=240,scrollbars=0');
return false;"></A>

Instead of opening a window of 480x240, the window is of 480x165.
Whatever dimensions I try, all created windows are 75 pixels too short in height.

This not occurs everytime, I remember it was doing the same on a previous build
then I switched to 1.7.3 and it didn't occured anymore... Until now.

That's why none of the developers have been able to reproduce it, because it
doesn't occur every time. Seems it only start to happens after a very long
period of use (several months). Note that when this bug happened once, it still
occurs after you reboot the computer.
Well, the height of my created windows were always to big (approx. 75 pixels).

I have used every available beta release and lots of nightlys since 1.5 without
uninstalling the old version before I installed the new one.

Now, I have deinstalled Moz, cleaned the program file folder (not the profile
folder) and reinstalled 1.8beta4. It was working fine for about one week now,
but today the same error occurs again :-(
I do only see the bug on my 8bit-museum.de but not on slabihoud.de. Both
websites use the same script so the bug seems to appear in combination with
something completly different.
Attached image wrong height
Ok, some more investigations:

Picture 1: shows that the window is about 70 pixels too hight.

Picture 2: I opened the sidebar and now the picture is too height and too width.

Picture 3: I closed the sidebar and closed the bookmarks and the windows is fine.

btw my bookmark folder contains really lots of bookmarks (approx. 1 mbyte file
size).
(In reply to comment #9)
> Ok, some more investigations:
> 
> Picture 1: shows that the window is about 70 pixels too hight.
> 
> Picture 2: I opened the sidebar and now the picture is too height and too width.
> 
> Picture 3: I closed the sidebar and closed the bookmarks and the windows is fine.
> 
> btw my bookmark folder contains really lots of bookmarks (approx. 1 mbyte file
> size).

My sidebar is always closed so I erased my bookmarks but the bug still happens. 
Coming over from bug 257036

Here is a dead-simple test case that illustrates the problem of the browser
opening a window the wrong size:

<HTML>
<SCRIPT LANGUAGE="Javascript">
window.open("", "foo", "width=400,height=100");
</SCRIPT>
<TITLE> Window opening test </TITLE>
<BODY>
Enable pop-ups to see this test case.
</BODY>
</HTML>

In Mozilla 1.7.3 it opens the correct height.
In Firefox 1.0 it opens ~25 pixels too big in a vertical direction.

Test case is here: http://www.mdarwin.ca/test/toolbar.html

Tested on Linux, applies to all O/Ses I've tried (Win2K, WinXP)

This broke sometime around Firefox preview release (0.9 was ok)
I clicked this link
<a href="javascript:PopUp(0,'Steven Wozniak und Steve
Jobs','../imgs/apple/jobswozniakg.jpg',640,451);">
at http://8bit-museum.de/docs/apple1.htm
with Mozilla 1.8b2 build 2005043006 and Firefox 1.0.3 rv: 1.7.7 build 20050414
under XP Pro SP2 and got in both cases a window with a viewport of precisely
640w x 451h .

Note that 
- "locationbar" is not a recognized windowFeature in any browser; "location",
OTOH, is
- theTitle, theWidth and theHeight are variables which do not seem to be used
- the width value does not include the sidebar if it is expanded
- there are other instructions over at
http://8bit-museum.de/tools.js
which may interfere or affect viewport dimensions 
  var NS  = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
  var IE  = (navigator.appName.indexOf("Microsoft Internet Explorer") != -1) ?
true : false;
  var IE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false;
  var IE4 = (navigator.appVersion.indexOf("MSIE 4") != -1) ? true : false;
(...)

Browser detection based on user agent string identification is unreliable and
never recommendable. Here, Mozilla and Firefox, even without changing the user
agent string are not "detected" as such. If the user agent string is modified,
then the new popup window may have different height values (ranging from -30 to +5).

function PopUp(Ort, Title, Path, Width, Height) {
(...)
  theTitle = Title;
  theWidth = Width;
  theHeight = Height;

  if (IE) {
    if (IE3)      { Width=Width+10; Height=Height-30; }
    if (VER=="4") { Width=Width+ 0; Height=Height+ 0; }
    if (VER>="5") { Width=Width+ 5; Height=Height+ 5; }
  }
  if (OP) {
    Width=Width+0; Height=Height+0;
  }
  if (NS) {
    Width=Width+0; Height=Height+0;
  }

  var winFeatures =
'dependent=yes,locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,width='
+ Width + ',height=' + Height;
  if (!IE3 && !IE4) if(popWin) if(!popWin.closed) popWin.close();
The above (3 if..then in cascade) does not make sense and is certainly an
abusive way to use the user's system resources: if the reference exists and if
the window is not closed, then close it just to re-create it entirely all over
again.
     
  if(OP) {
    popWin = window.open('toolshtml.htm', 'PopWin' + imgCount++, winFeatures);
  } else {
    popWin = window.open('toolshtml.htm', 'PopWin' + imgCount++, winFeatures);
  }
The then instruction is the same as the else one.
}

I can not reproduce the problem; I get what should be the expected results.
Stephan, if the problem still occurs in a recent build and with a new profile,
then you may reopen this bug: if so, please try to provide and attach in this
bugfile a reduced testcase with explicit actual and expected results.

Resolving as WORKSFORME
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → WORKSFORME
Whiteboard: DUPEME
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: