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: 349
  • Last Modified:

open new window, close old window

I want to make a script that will open a new window and close the page with that new window script (old one)

Milcoi
0
Milcoi
Asked:
Milcoi
1 Solution
 
archrajanCommented:
Try this:
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function doit()
{
var a = window.open('http://www.yahoo.com','yahoo','width=600,height =800')
self.close();
}
</script>
</HEAD>

<BODY>
<a href = "#" onclick = "doit();return false;">OPEN NEW AND CLOSE THIS</a>
</BODY>
</HTML>



Note: u cannot bypass the confirmation message when closing the main window
0
 
str_kaniCommented:
creat two pages say :  parent.html and child.html
I am going to open a new window from the parent and close the parent window from child... WITHOUT any confirmation....

1. create a file parent.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE> Parent</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function open_new_window()
{
 window.open('child.html','new','width=100,height=100')
 window.opener ="_top";
}
</SCRIPT></HEAD>

<BODY onload="open_new_window();">

</BODY>
</HTML>



2.create another html file child.html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE> Child </TITLE>
<SCRIPT LANGUAGE="JavaScript">
function close_parent_window()
{
if(!window.opener.closed)
{
window.opener.close();
      }
}
</SCRIPT></HEAD>

<BODY onload="close_parent_window();">

</BODY>
</HTML>


3. That's it

Enjoy
0
 
str_kaniCommented:
This trick is not necessary in Mozilla, Explorer on Mac, Opera and OmniWeb.

This trick does not work in Netscape 4 and lower, Safari, iCab and Explorer 5.0 Windows.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
MilcoiAuthor Commented:
sory, I found this and works perfect

<html>
<head>
<script type="text/JavaScript">
function openWin()
{
window.open('your-url-here.html?I+','','width=588,height=588,top=10,left=10,resizable=no,scrollbars=yes,locationbar=no,menubar=no,fullscreen=no');
window.opener=null;
window.close();
}
</script>
</head>
<body onload="openWin()">

</body>
</html>
0
 
Andrew BeersTechnology LeadCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

http:Q_21402494.html--> PAQ - Refund

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

~Aqua
EE Cleanup Volunteer
0
 
moduloCommented:
PAQed with points refunded (100)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now