Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Window.close question

Status
Not open for further replies.

shaunk

Programmer
Aug 20, 2001
402
AU
Ok, this is basic stuff but after reading about this function from several internert resources, none of them mentions that the command prompts the user if closing the window is OK.

I have this code, which should close the current window , and open another one based on the the day of the week. It works OK..but then again that prompt is not preferred.

<html>
<head>
<title>Date_Check</title>
<script>
function start(){
var today=new Date();
var NowDay = today.getDay();
if (NowDay == 5)
{
window.close("Date_Check");
window.open("Not_Today.asp");
}
}

</SCRIPT>
</head>

<body bgcolor="#FFFFFF" text="#000000" onLoad="start()">
 
I believe the rule is you can close a window you opened without a prompt, but you cant close a window the user opened without a prompt.

It might be easier if you try something like this instead:

Code:
<html>
<head>
<title>Date_Check</title>
<script>
function start(){
   var today=new Date();
   var NowDay = today.getDay();
   if (NowDay == 5)
   {
[COLOR=red]  this.window.location='Not_Today.asp';[/color]
   }
}

</SCRIPT>
</head>

<body bgcolor="#FFFFFF" text="#000000" onLoad="start()">

Hope that helps.

Drew

&quot;Mistakes are the portals of discovery&quot;
James Joyce
 
This should work
Code:
<html>
<head>
<title>Date_Check</title>
<script>
function start(){
   var today=new Date();
   var NowDay = today.getDay();
   if (NowDay == 5)
   {
   self.opener=this;
  self.close();
   window.open("Not_Today.asp");
   }
}

</SCRIPT>
Hope this helps.

Glen
 
Glen,

I think I read somewhere recently that Microsoft "patched" that feature out of IE... Can anyone [with all the latest patches installed] confirm this?

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top