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

Open new window and close existing windows?

P: n/a
Could use your assistance with this. I have a window that opens via
onclick and it is a small window with info about a site. If the user
is interested in visiting that site, there is a link to click that
opens the site in a new and larger window via onclick. My question
is, can I have the smaller window automatically close when the user
clicks the link to visit the site? I also have a link that merely
closes the smaller info window if the user is not interested in
visiting the site.

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


P: n/a
Hi,

Carol Lyn wrote:
Could use your assistance with this. I have a window that opens via
onclick and it is a small window with info about a site. If the user
is interested in visiting that site, there is a link to click that
opens the site in a new and larger window via onclick. My question
is, can I have the smaller window automatically close when the user
clicks the link to visit the site? I also have a link that merely
closes the smaller info window if the user is not interested in
visiting the site.

TIA


To load the link in the main window and close the small window, do:

<A HREF="newLocation.html"
ONCLICK="opener.location=this.href;top.close()retu rn false;">
Click here</A>

Of course, this won't work if JavaScript is not enabled.

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #2

P: n/a
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:3F042498.9060806@bluewin_NO_SPAM.ch...
Hi,

Carol Lyn wrote:
Could use your assistance with this. I have a window that opens via
onclick and it is a small window with info about a site. If the user
is interested in visiting that site, there is a link to click that
opens the site in a new and larger window via onclick. My question
is, can I have the smaller window automatically close when the user
clicks the link to visit the site? I also have a link that merely
closes the smaller info window if the user is not interested in
visiting the site.

TIA


To load the link in the main window and close the small window, do:

<A HREF="newLocation.html"
ONCLICK="opener.location=this.href;top.close()retu rn false;">
Click here</A>

Of course, this won't work if JavaScript is not enabled.

Laurent


Hello. Could this procedure also include window options, specifically,
resizing the main window to be larger than the smaller info window that
closes?

Cheers,
Jul 20 '05 #3

P: n/a
Hi,

marcy wrote:
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:3F042498.9060806@bluewin_NO_SPAM.ch...
Hi,

Carol Lyn wrote:
Could use your assistance with this. I have a window that opens via
onclick and it is a small window with info about a site. If the user
is interested in visiting that site, there is a link to click that
opens the site in a new and larger window via onclick. My question
is, can I have the smaller window automatically close when the user
clicks the link to visit the site? I also have a link that merely
closes the smaller info window if the user is not interested in
visiting the site.

TIA


To load the link in the main window and close the small window, do:

<A HREF="newLocation.html"
ONCLICK="opener.location=this.href;top.close()retu rn false;">
Click here</A>
Forgot a ';' here. Should be

<A HREF="newLocation.html"
ONCLICK="opener.location=this.href;top.close();ret urn false;">
Click here</A>

Of course, this won't work if JavaScript is not enabled.

Laurent

Hello. Could this procedure also include window options, specifically,
resizing the main window to be larger than the smaller info window that
closes?

Cheers,


Before I show you how to do this, note that noone likes his browser
window to be resized. I strongly advocate against doing this.

However, it is technically possible to resize a window from another one,
with

windowRef.resizeTo( WIDTH, HEIGHT );

For example:

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--

function closeAndResize( iWidth, iHeight, strNewLoc )
{
opener.location = strNewLoc;
opener.resizeTo( iWidth, iHeight );
top.close();
}

//-->
</SCRIPT>

<A HREF="http://www.galasoft-LB.ch"
ONCLICK="closeAndResize( 600, 800, this.href );return false;">
Click here</A>

Don't use it ;-)

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #4

P: n/a
DU
Laurent Bugnion, GalaSoft wrote:
Hi,

marcy wrote:
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:3F042498.9060806@bluewin_NO_SPAM.ch...
Hi,

Carol Lyn wrote:

Could use your assistance with this. I have a window that opens via
onclick and it is a small window with info about a site. If the user
is interested in visiting that site, there is a link to click that
opens the site in a new and larger window via onclick. My question
is, can I have the smaller window automatically close when the user
clicks the link to visit the site? I also have a link that merely
closes the smaller info window if the user is not interested in
visiting the site.

TIA
To load the link in the main window and close the small window, do:

<A HREF="newLocation.html"
ONCLICK="opener.location=this.href;top.close()retu rn false;">
Click here</A>

Forgot a ';' here. Should be

<A HREF="newLocation.html"
ONCLICK="opener.location=this.href;top.close();ret urn false;">
Click here</A>

Of course, this won't work if JavaScript is not enabled.

Laurent
Hello. Could this procedure also include window options, specifically,
resizing the main window to be larger than the smaller info window that
closes?

Cheers,

Before I show you how to do this, note that noone likes his browser
window to be resized. I strongly advocate against doing this.

However, it is technically possible to resize a window from another one,
with

windowRef.resizeTo( WIDTH, HEIGHT );


In NS 6.2+ and Mozilla-based browsers (NS 6.2+, K-meleon, Phoenix,
Firebird, Beonex, etc.), there is an user setting disableing,
neutralizing the recourse to resizeTo. So, resizeTo() can not be
considered as a reliable method. I personally always have this setting
turning off resizeTo() calls.

Not to mention that Bugzilla has also enhancement requests where the
user will utlimately have more control over and absolute veto over the
javascript requests of web developers over window dimensions. I
wholeheartedly agree with these people since a web developer has no idea
how big/small is a monitor screen, how acute is the eye vision of an
user, how crowded is the window screen, etc.. and this is outside his
range and control. Leave the window sizes to the only person who will be
using that window: the user. He's the best person to know what's the
best window size for his needs.
For example:

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--

function closeAndResize( iWidth, iHeight, strNewLoc )
{
opener.location = strNewLoc;
opener.resizeTo( iWidth, iHeight );
top.close();
}

//-->
</SCRIPT>

<A HREF="http://www.galasoft-LB.ch"
ONCLICK="closeAndResize( 600, 800, this.href );return false;">
On a 800x600 scr. res. - which is the most popular scr. res. - , the
above instruction, if it succeeds, will create a 600x572 window because
the requested 800 height will not fit within the available workarea for
application. That's just a good - unintentional - example here why it is
not recommendable to try to control the window dimensions.
Click here</A>

Don't use it ;-)

Laurent

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #5

P: n/a
On Wed, 09 Jul 2003 05:06:28 -0400, DU <dr*******@hotREMOVEmail.com>
wrote:
Laurent Bugnion, GalaSoft wrote:
Hi,

marcy wrote:
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:3F042498.9060806@bluewin_NO_SPAM.ch...

Hi,

Carol Lyn wrote:

> Could use your assistance with this. I have a window that opens via
> onclick and it is a small window with info about a site. If the user
> is interested in visiting that site, there is a link to click that
> opens the site in a new and larger window via onclick. My question
> is, can I have the smaller window automatically close when the user
> clicks the link to visit the site? I also have a link that merely
> closes the smaller info window if the user is not interested in
> visiting the site.
>
> TIA
To load the link in the main window and close the small window, do:

<A HREF="newLocation.html"
ONCLICK="opener.location=this.href;top.close()retu rn false;">
Click here</A>

Forgot a ';' here. Should be

<A HREF="newLocation.html"
ONCLICK="opener.location=this.href;top.close();ret urn false;">
Click here</A>

Of course, this won't work if JavaScript is not enabled.

Laurent

Hello. Could this procedure also include window options, specifically,
resizing the main window to be larger than the smaller info window that
closes?

Cheers,

Before I show you how to do this, note that noone likes his browser
window to be resized. I strongly advocate against doing this.

However, it is technically possible to resize a window from another one,
with

windowRef.resizeTo( WIDTH, HEIGHT );


In NS 6.2+ and Mozilla-based browsers (NS 6.2+, K-meleon, Phoenix,
Firebird, Beonex, etc.), there is an user setting disableing,
neutralizing the recourse to resizeTo. So, resizeTo() can not be
considered as a reliable method. I personally always have this setting
turning off resizeTo() calls.

Not to mention that Bugzilla has also enhancement requests where the
user will utlimately have more control over and absolute veto over the
javascript requests of web developers over window dimensions. I
wholeheartedly agree with these people since a web developer has no idea
how big/small is a monitor screen, how acute is the eye vision of an
user, how crowded is the window screen, etc.. and this is outside his
range and control. Leave the window sizes to the only person who will be
using that window: the user. He's the best person to know what's the
best window size for his needs.
For example:

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--

function closeAndResize( iWidth, iHeight, strNewLoc )
{
opener.location = strNewLoc;
opener.resizeTo( iWidth, iHeight );
top.close();
}

//-->
</SCRIPT>

<A HREF="http://www.galasoft-LB.ch"
ONCLICK="closeAndResize( 600, 800, this.href );return false;">


On a 800x600 scr. res. - which is the most popular scr. res. - , the
above instruction, if it succeeds, will create a 600x572 window because
the requested 800 height will not fit within the available workarea for
application. That's just a good - unintentional - example here why it is
not recommendable to try to control the window dimensions.
Click here</A>

Don't use it ;-)

Laurent

DU


Yes, I have taken the advice and it works out best. Actually,
Laurent's follow-up mentioning the semi-colon made all the difference
(thank you for returning with that info) because our new window was
opening in the much smaller info window. That's why I was curious
about the ability to resize the new window. But making that
semi-colon adjustment solved that issue and the new window opens up
full while the smaller info window goes away. Perfect. Thanks, All,
for your assistance!
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.