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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple : window.close()

Status
Not open for further replies.

pcawdron

Programmer
Jun 14, 2000
109
0
0
AU
How can I stop the window.close() method from prompting the user as to whether he wants the window closed or not?

I'm using a log on screen to launch a full screen ASP window in a new window, which, once launched, no longer needs the log on screen, but I can't get the first screen to close without ie 5.5 asking the user for permission to close the window.

Any ideas?
 
<script type=&quot;text/javascript&quot;>
<!--
function byebye() {
if(! confirm(&quot;are u sure u wish to quit ?&quot;)) {
return;
} else {
alert(&quot;see ya later friend&quot;);
window.close();
}
}
//-->
</script>

<body onunload=&quot;byebye()&quot;> ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
NeverSleep, thanks for the quick reply... but I don't want any alert boxes at all....

I need someway of avoiding the generic prompt, the user clicks on a hyperlink and he's away without any further ado :)

Any more ideas?
 
window.close() shots a alert ??? i have IE6 & NS6
if i type
javascript:window.close() (same as href=&quot;javascript:wi...&quot;)
at the url bar the window closes ! ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Yeah... I can't figure it out either, my code is...

<a href=&quot;javascript:OpenNewWin()&quot;>Open</a>
<script language=&quot;javascript&quot;>
function OpenNewWin(){
winOpen = window.open(&quot;&quot;,&quot;NewWin&quot;,&quot;fullscreen&quot;);
winOpen.document.write('<HTML><BODY>Loading.... please wait...</BODY></HTML>')
winOpen.focus();
//This opens the window gradually to fill 800x600 screen
//while still leaving the start bar visible
for (H=1;H<550;H+= 20) {
winOpen.resizeTo(1,H);
}
for (W=1;W<800;W+= 20) {
winOpen.resizeTo(W,H);
}
winOpen.location = 'Target page';
winOpen.creator=self
winOpen.focus()
window.close()
//self.close()
}
</script>

Just tested the code above again, using a local target page and, sure enough, it launches the new page correctly but still brings up the ie message about closing the original page
 
I actually have the same problem and have not been able to resolve it. Could someone be a hero[medal] to two people?
I've made the site a trusted local intranet site (which it is) with the lowest security and it still prompts.

Unlike NEVERSLEEP, when I type javascript:window.close() in the URL bar, it does prompt me.

I would imagine it is some level of security, but, as I said, that path has not been fruitful for me.

my simple test page code is this....

Code:
<%
 Response.Write &quot;<HTML> HELLO </HTML> &quot;
 
%>
<script language=&quot;JavaScript&quot; >
self.close()
</script>

Thanks,
bojisheng
 
I've tried too...I think this is a security precaution in Javascript: how would you like it if a site was able to instantly close your only open browser window without asking?
 
&quot;If you invoke the close() method on a window that you did not open with script, a confirm dialog box lets the user choose whether the window closes. Navigator doesn't invoke the dialog box if the window has only one document (the current one) in its session history. However, if you use close() to exit the last running instance of the browser, the confirm box pops up (both browsers).&quot;


unless you've spawned the window you want to close from somewhere else, then you can't close it without a confirmation.

yeah it's not good, but that's life.

mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top