?
Solved

Open New Window and close Previous window

Posted on 2003-03-21
11
Medium Priority
?
600 Views
Last Modified: 2008-01-16

I'm looking for a script that will automatically open a new window when the page is loaded and will close the initial window. The new window will need to have a height of 450 and width of 95%. I will also need the option to choose whether or not to show browser elements.

Any suggestions?
0
Comment
Question by:dumbASP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
11 Comments
 
LVL 10

Expert Comment

by:apollois
ID: 8183073
Hi dumbASP,

Use the BODY onLoad event to call a custom Javascript function.  Let me know if you have any questions.

================================================
<HTML>
<HEAD>

<script LANGUAGE="javascript">
<!--

//---------------------------------------------------------------------
function DisplayWindow(pcURL) {
//---------------------------------------------------------------------
         
     var popup;
     var intWidth      = 518;
     var intHeight      = 700;
     var intTop           = 0;    
     var intLeft      = 400;
     var strFeatures = 'toolbar=0,scrollbars=1,location=0, '
                    + 'statusbar=0,menubar=0,resizable=1,'
                    + 'width='+intWidth+',height='+intHeight+',left ='+intLeft+',top ='+intTop+'';
                   
     popup = window.open(pcURL, "HealthPlan", strFeatures);
     
     //Close Original Window -- this will cause a confirmation dialog box
     //to be displayed to the user.  You cannot avoid this.

     window.close
}
//-->
</script>

</HEAD>
<BODY onLoad="DisplayWindow('NewWindowURL.asp');">
</BODY>
</HTML>

================================================

Best Regards,
>apollois<
0
 

Author Comment

by:dumbASP
ID: 8183476


The open in new window portion works great .. thanks...

However... the close window portion is not working. It is simply leaving a blank window open on the screen.
0
 
LVL 3

Expert Comment

by:DRY_GIN
ID: 8183502
window.close();
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Accepted Solution

by:
apollois earned 600 total points
ID: 8183577
dumbASP,

>>>      window.close <<<

I forgot the parenthesis on the close method.  Change to:

window.close()


Best Regards,
>apollois<
0
 
LVL 34

Expert Comment

by:arbert
ID: 8183743
Don't know your exact situation, why don't you just resize the current window instead of launching a new one and then closing the old one????


window.resizeTo(400,300)
window.location.href='blahblahblah.htm'


Brett
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 8184164
i would also go with resizing... because the user gets asked, if he really allows you to close the parent window...
to avoid this, just resize the win...

ASPGuru
0
 
LVL 10

Expert Comment

by:apollois
ID: 8184211
ASPGuru,

>>> i would also go with resizing. <<<

Resizing avoids the close window dialog, but does not allow you to remove the browser menus/bars.  Sometimes you want to present a clean window without all the browser menus/bars/etc.  I often do this in apps where I have a main page that spawns "sub-windows".  It looks more professional -- almost like a windows app. <bg>

Best Regards,
>apollois<
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 8184232
yea sure... everything has benefits and drawbacks...

dumbASP needs to decide...

ASPGuru
0
 
LVL 3

Expert Comment

by:DRY_GIN
ID: 8184669
i'm not getting any warnings on window.close();..
is it because windows.close() executed from within a child pop-up window?
0
 
LVL 10

Expert Comment

by:apollois
ID: 8184689
DRY_GIN,

>>> i'm not getting any warnings on window.close();.. <<<

If you create the window, you can close it without warning.

Best Regards,
>apollois<
0
 
LVL 58

Expert Comment

by:Gary
ID: 9313353
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by apollois

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question