By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,703 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

Multiple Popup windows

P: n/a
Hello,

I've a problem I hava a page with different popup windows,
when I hit a link the first one pops up and with the first open i would like
to hit the second link in the parent page so the second links pops up a
window in
the first popup. The way I have it now is working but with each link the
size
of the popup window should be different but that doesnt happen how can I
solve that problem?

this is my code:

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops =
'height='+h+',width='+w+',top='+wint+',left='+winl +',scrollbars='+scroll+',r
esizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
the first link:
<a href="#"
onClick="NewWindow('info_banketquiz.html','name',' 488','255');return
false;">info</a>
the second link:
<a href="#"
onClick="NewWindow('info_consumenten.html','name', '488','405');return
false;">info</a>
I hope that somebody can help me

Greetings Willem
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Willem van Isselmuden" <is********@hotmail.com> writes:
the first popup. The way I have it now is working but with each link
the size of the popup window should be different but that doesnt
happen
how can I solve that problem? function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
It is safer not to position the new window. Positioning a window
realtive to the screen gives trouble for MDI browsers (like Opera) and
multi monitor setups. Letting the browser place the window will
most likely give an acceptable result for everybody.

Remember to make windows resizable and/or allow scrollbars. No matter
what you might think you are prepared for, there will always be some
person with a setup that makes the content overflow. (Me, e.g., as I
have a user stylesheet that adds content after links with a target
attribute, and a rule that locks the font-size of the body document to
100%).
the first link:
<a href="#"
onClick="NewWindow('info_banketquiz.html','name',' 488','255');return
false;">info</a>
the second link:
<a href="#"
onClick="NewWindow('info_consumenten.html','name', '488','405');return
false;">info</a>


You open both windows with the same name (in fact the name "name").
That means that the second call to window.open will reuse the window,
and the configuration options are ignored.

You will either have to close the window and open it again, or just
resize it directly (with either the .resizeTo or the .resizeBy method).
Be aware that the resizeXX methods set the outer size of the window,
while the window.open configuration string sets the inner width and
height.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
"Willem van Isselmuden" <is********@hotmail.com> wrote in message news:<bj**********@news2.tilbu1.nb.home.nl>...
Hello,

I've a problem I hava a page with different popup windows,
when I hit a link the first one pops up and with the first open i would like
to hit the second link in the parent page so the second links pops up a
window in
the first popup. The way I have it now is working but with each link the
size
of the popup window should be different but that doesnt happen how can I
solve that problem?

this is my code:

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops =
'height='+h+',width='+w+',top='+wint+',left='+winl +',scrollbars='+scroll+',r
esizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
the first link:
<a href="#"
onClick="NewWindow('info_banketquiz.html','name',' 488','255');return
false;">info</a>
the second link:
<a href="#"
onClick="NewWindow('info_consumenten.html','name', '488','405');return
false;">info</a>
I hope that somebody can help me

Greetings Willem


Not a solution, but you could close the first pop up before opening
the second, as

<script type='text/javascript'>
var win;
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var winprops = 'height=' + h + ',width=' + w + ',top=' +
wint + ',left=' + winl + ',scrollbars=' + scroll
+ ',resizable';
if(win)
win.close();
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

</script>
<a href="#" onClick="NewWindow('info1.htm','name','488','255') ;return
false;">info</a>
<br>
<a href="#" onClick="NewWindow('info2.htm','name','488','405') ; return
false;">info2</a>
Jul 20 '05 #3

P: n/a
DU
Greg wrote:
"Willem van Isselmuden" <is********@hotmail.com> wrote in message news:<bj**********@news2.tilbu1.nb.home.nl>...
Hello,

I've a problem I hava a page with different popup windows,
when I hit a link the first one pops up and with the first open i would like
to hit the second link in the parent page so the second links pops up a
window in
the first popup. The way I have it now is working but with each link the
size
of the popup window should be different but that doesnt happen how can I
solve that problem?

this is my code:

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops =
'height='+h+',width='+w+',top='+wint+',left='+wi nl+',scrollbars='+scroll+',r
esizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
the first link:
<a href="#"
onClick="NewWindow('info_banketquiz.html','name' ,'488','255');return
false;">info</a>
the second link:
<a href="#"
onClick="NewWindow('info_consumenten.html','name ','488','405');return
false;">info</a>
I hope that somebody can help me

Greetings Willem

Not a solution, but you could close the first pop up before opening
the second,


[snipped]

But then you would not use efficiently the user's system resources. Why
not simply load a different url into an already created and opened popup?

If the window object reference exists and is opened and if the url is
different, then load the new url into the existing popup. This is what I
do in several of my pages.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #4

P: n/a
DU
Willem van Isselmuden wrote:
Hello,

I've a problem I hava a page with different popup windows,
when I hit a link the first one pops up and with the first open i would like
to hit the second link in the parent page so the second links pops up a
window in
the first popup. The way I have it now is working but with each link the
size
of the popup window should be different but that doesnt happen how can I
solve that problem?

this is my code:

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops =
'height='+h+',width='+w+',top='+wint+',left='+winl +',scrollbars='+scroll+',r
esizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

This is a popular script function and a bad one.

It should be rather
var winl = Math.round((screen.availWidth - w) / 2);
var wint = Math.round((screen.availHeight - h) / 2);

winprops =

'height='+h+',width='+w+',top='+wint+',left='+winl +',scrollbars='+scroll+',r
esizable'

If mypage is a referenced image, then the height and width of the window
can not be the height and width of the image because all browsers have
default css values for margin or padding on the body element, the
largest ones (margin:15px 10px;) being those of MSIE 5+. I mention this
because this script is a popular one and people copy it often without
knowing details like that.

Allowing the script to turn off scrollbars is anti-usability and
anti-accessibility. With "scrollbars=yes", scrollbar(s) will appear only
if content overflows window's dimensions: so, why would you want to turn
off scrollbar(s) if your window needs them, if scrollbars are needed?
After a first mistake - content might overflow window dimensions -, the
popup definitively could need scrollbars. In case of doubt (say, user
uses large font size), then it is always safer to allow scrollbar(s) to
appear if they are needed. Even if you could know in advance if the
font-size makes the content fits perfectly in the window, increasing
font later might prevent scrollbars from appearing. This is an important
detail if the popup can lead to other referenced resources.

win = window.open(mypage, myname, winprops)

The window object reference needs to be declared as a global variable,
preferably not in the function body.

if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

I do not understand this line at all. If you just created a window, then
you don't need to give it focus, obviously. In any case, checking the
appVersion is not reliable... whatever what was the intent behind this.


the first link:
<a href="#"
onClick="NewWindow('info_banketquiz.html','name',' 488','255');return
false;">info</a>
There is no 5th argument. So, info_banketquiz.html will not be a
scrollable window if content overflows window's dimensions: this is not
recommendable. Also, if the window dimensions do not consider margin
(padding:8px in Opera 7) on the body element, then the content might
overflow requested dimensions... which happens often. Almost all
dynamicdrive.com scripts about popups or involving popups have such
oversight and such problem.

If javascript is disabled, then the resource is not accessible at all
.... when it should still be accessible.

<a href="info_banketquiz.html" target="name"
onClick="NewWindow(this.href, this.target,'488','255');return
false;">info</a>

would correct this though.


the second link:
<a href="#"
onClick="NewWindow('info_consumenten.html','name', '488','405');return
false;">info</a>
I hope that somebody can help me

Greetings Willem


Go to this page

http://www10.brinkster.com/doctorunc...pera7Bugs.html

and examine the function OpenRequestedPopup(strUrl)

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #5

P: n/a
DU
DU wrote:
Greg wrote:
"Willem van Isselmuden" <is********@hotmail.com> wrote in message
news:<bj**********@news2.tilbu1.nb.home.nl>...
Hello,

I've a problem I hava a page with different popup windows,
when I hit a link the first one pops up and with the first open i
would like
to hit the second link in the parent page so the second links pops up a
window in
the first popup. The way I have it now is working but with each link the
size
of the popup window should be different but that doesnt happen how can I
solve that problem?

this is my code:

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops =
'height='+h+',width='+w+',top='+wint+',left='+winl +',scrollbars='+scroll+',r

esizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
the first link:
<a href="#"
onClick="NewWindow('info_banketquiz.html','name',' 488','255');return
false;">info</a>
the second link:
<a href="#"
onClick="NewWindow('info_consumenten.html','name', '488','405');return
false;">info</a>
I hope that somebody can help me

Greetings Willem


Not a solution, but you could close the first pop up before opening
the second,

[snipped]

But then you would not use efficiently the user's system resources. Why
not simply load a different url into an already created and opened popup?

If the window object reference exists and is opened and if the url is
different, then load the new url into the existing popup. This is what I
do in several of my pages.


....unless the requested window toolbars, requested window dimensions,
etc... are different... which is the case here in the given code as both
popups have different heights.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.