Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

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?
0
dumbASP
Asked:
dumbASP
  • 4
  • 2
  • 2
  • +3
1 Solution
 
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
apolloisCommented:
dumbASP,

>>>      window.close <<<

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

window.close()


Best Regards,
>apollois<
0
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now