Open New Window and close Previous window


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?
dumbASPAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

apolloisCommented:
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
dumbASPAuthor Commented:


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
DRY_GINCommented:
window.close();
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

apolloisCommented:
dumbASP,

>>>      window.close <<<

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

window.close()


Best Regards,
>apollois<
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arbertCommented:
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
ASPGuruCommented:
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
apolloisCommented:
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
ASPGuruCommented:
yea sure... everything has benefits and drawbacks...

dumbASP needs to decide...

ASPGuru
0
DRY_GINCommented:
i'm not getting any warnings on window.close();..
is it because windows.close() executed from within a child pop-up window?
0
apolloisCommented:
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
GaryCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.