469,643 Members | 1,890 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

new window

Den
Hi, I have one simple question:
Code:
------------
<html>
<body>
<input type="button" onclick="openWindow('http://www.google.com', 'Google')"
value="Google">
</body>
<script language="JavaScript">
function openWindow(adress,name, height, width) {
window.open(adress,name,"height="+height+", width="+width);
}
</script>
</html>
------------

This is the most simple new-window script. But I discovered something:

In IE6:
When page is uploaded on webserver, script is opening one very small window
(c. 120x160) after the click on gooogle button. That is logical, as there
is no 'height' and 'width' values. But when I run this page from my desktop,
it opens one big c. 1024x768 window (my monitor resolution is 1280x1024).

Why is that?

Firefox opens the same size window in both cases (c. 900x1000). Netscape
opens identical windows too, just smaller (c. 120x130).

Den
Aug 20 '05 #1
5 1320
Lee
Den said:

Hi, I have one simple question:
Code:
------------
<html>
<body>
<input type="button" onclick="openWindow('http://www.google.com', 'Google')"
value="Google">
</body>
<script language="JavaScript">
function openWindow(adress,name, height, width) {
window.open(adress,name,"height="+height+", width="+width);


You're passing four arguments to a function that expects three,
and the syntax of the third argument is wrong (since the "height"
variable is not passed a value. It's not surprising that browsers
do unexpected things, or that they don't all do the same thing.

Aug 20 '05 #2
Guy


Den a écrit:
Hi, I have one simple question:
Code:
------------
<html>
<body>
<input type="button" onclick="openWindow('http://www.google.com', 'Google')"
value="Google">
</body>
<script language="JavaScript">
function openWindow(adress,name, height, width) {
window.open(adress,name,"height="+height+", width="+width);
window.open(adress,name,'"height='+height+', width='+width +'"');

sample :

window.open(adress,name,"toolbar=no,scrollbars=yes ,resizable=yes,
height=550, width=850")

Guy }
</script>
</html>
------------

This is the most simple new-window script. But I discovered something:

In IE6:
When page is uploaded on webserver, script is opening one very small window
(c. 120x160) after the click on gooogle button. That is logical, as there
is no 'height' and 'width' values. But when I run this page from my desktop,
it opens one big c. 1024x768 window (my monitor resolution is 1280x1024).

Why is that?

Firefox opens the same size window in both cases (c. 900x1000). Netscape
opens identical windows too, just smaller (c. 120x130).

Den


Aug 20 '05 #3
Lee wrote:
Den said:
Hi, I have one simple question:
Code:
------------
<html>
<body>
<input type="button" onclick="openWindow('http://www.google.com', 'Google')"
value="Google">
</body>
<script language="JavaScript">
function openWindow(adress,name, height, width) {
window.open(adress,name,"height="+height+", width="+width);


window.open(adress,name,"height="+height+",width=" +width);

Mick

You're passing four arguments to a function that expects three,
and the syntax of the third argument is wrong (since the "height"
variable is not passed a value. It's not surprising that browsers
do unexpected things, or that they don't all do the same thing.

Aug 20 '05 #4
Guy a écrit :


Den a écrit:
Hi, I have one simple question:
Code:
------------
<html>
<body>
<input type="button" onclick="openWindow('http://www.google.com',
'Google')" value="Google">
</body>
<script language="JavaScript">
It should be <script type="text/javascript">

var WindowObjectReference = null;
// global variable declaration and initialisation
function openWindow(adress,name, height, width) {
window.open(adress,name,"height="+height+", width="+width);


window.open(adress,name,"height="+height+", width="+width);
-------------------------------------------^

There should not be any blank space in the 3rd parameter (windowFeatures
string list).

window.open(adress,name,'"height='+height+', width='+width +'"');

sample :

window.open(adress,name,"toolbar=no,scrollbars=yes ,resizable=yes,
height=550, width=850")

Guy


WindowObjectReference = window.open(adress, name,
"scrollbars=yes,resizable=yes,height=550,width=850 ");

1- no blank space in the 3rd parameter, in the windowFeatures string list
2- With height=550,width=850 values, users with a 800x600 will have the
secondary window resize automatically in Mozilla-based browsers and in
MSIE 6 SP2 due to error correction mechanism ensuring that the whole
window is rendered in the available space of the screen.
3- Storing the return value of the window.open() call is often useful.

DOM:window.open()
Best practices
http://developer.mozilla.org/en/docs...Best_practices

Gérard
Aug 21 '05 #5
Den
Thanks for answers :)

Den
Aug 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Carol Lyn | last post: by
6 posts views Thread by David Hayes | last post: by
19 posts views Thread by Darren | last post: by
14 posts views Thread by D. Alvarado | last post: by
26 posts views Thread by yb | last post: by
4 posts views Thread by alexandre.brisebois | last post: by
24 posts views Thread by Jeremy J Starcher | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.