473,394 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Multiple Popup windows

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
5 11564
"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
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dan | last post by:
First, I'm sorry if this question has been asked too many times. I'm new to this news group. The question has to do with the use of popup windows in a web page. I have heard that popup windows...
6
by: nizar.jouini | last post by:
I have web page that contains two links. link "a" and link "b". When I click on "a" a small window should pop up. when I click on "b" another small window should pop up. So what you should see now...
7
by: bu | last post by:
I have a form with a handful of comments fields. I am trying to code the form in such a way that when the user clicks on the field, a dialog box will open up displaying the full contents of the...
1
by: .Net Newbie | last post by:
I am relatively new to .Net and have been coding an intranet site for my employer for a couple of months. I am currently stuck coding in a text-editor called EditPlus without access to the VS.Net...
0
by: .Net Newbie | last post by:
I am relatively new to .Net and have been coding an intranet site for my employer for a couple of months. I am currently stuck coding in a text-editor called EditPlus without access to the VS.Net...
2
by: Shashi | last post by:
My development environment is ASP.Net 1.1. When the user does multiple logins to the system and navigates to different screens and clicks back button sometimes it reading the session variables...
1
by: SteveComplex | last post by:
I'm currently working on a project developing a web application that makes heavy use of 3rd-party controls, popup windows and frames ( not my design I hasten to add ). Some of the pages make use...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.