nath

Microsoft IE Developers,

The question, everybody seems to be asking!

What are our alternatives regarding not prompting users when we are automatically closing a browser

Life was so much easier before IE7. I could simply use:

window.open("page.aspx","_blank","resizable=yes,scrollbars=yes,toolbar=no,status=yes");

window.opener = top;

window.close()

which would work perfectly for what I am trying to achieve for my ¡®trusted intranet web applications¡¯.

How can I launch a browser for a ¡®trusted intranet web application¡¯ that only displaying the title and status bars in IE7

Should I be looking at .hta files to launch a new web browser as they apparently allow window.close() to work However, there are extremely limited examples on the web.

PLEASE, shed some light on this¡­! I can understand implementing this prompt as security feature, but to not allow ¡®trusted intranet web applications¡¯ is just mind boggling!

Am I taking the wrong approach here¡­



Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Wagepeace007

Use .HTA's.

If you're creating true trusted intranet appplications then you should use HTA anyway as they will allow you to access the file system object, command line arguments, etc.

You really dont need any sort of example on how to use .HTAs, they're really nothing more than regular web pages with decreased security restrictions. Simply rename your .html file to have a .hta extension (ie test.html -> test.hta).

The only tag that is exclusive to an HTA is the <HTA> tag. This is a meta tag that provides information about the HTA and lets you customize the app's border, icon, etc.

An example follows:

<HTA:APPLICATION id="myHta" icon="C:\webpage\myIcon.ico" />

You can find the reference w/ all of the attributes and properties for the HTA object in MSDN, just run a search for it.





Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

pnarsavage

I've had the same issue... and did a bit of research on my own to see if I could find a work-around for this.

I have created a simple testing example online to try out different methods of opening new windows and having them self-close: http://sky.prohosting.com/savage25/AutoCloseExample.html
As you can see from the descriptions within it, IE6 and IE7 react differently in several of the cases. Hence the "issue" that IE7 has created...

In particular, the one that is causing me issues is the FORM submission using a "_blank" target window. It closes without confirmation in IE6, but does not in IE7.

A work-around that I discovered: IE7 may actually have become less secure when JAVASCRIPT redirects the current page (within the same window), and then this redirected-to site closes the window... the page then closes without any confirmation. I was able to use this "bug" ( ) to my advantage as a work-around to solve the problem.

Instead of calling "window.close()" to close the current window... do this:

window.open('close.html', '_self');

Where "close.html" contains:

<html><body>
<script language="JavaScript">window.close();</script>
</body></html>

This should work in both IE6 and IE7 to close the current window without confirmation.
I am currently using it in my application and it works well.

Paul Narsavage
Bethlehem, PA, USA
savage_25 at yahoo.com





Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Frank.Lin

Paul,

I've been searching numerous forums and websites for a solution to the same issue for a better half of the day, nothing worked for IE7 until I found this.
I applied your script and it works perfectly for my purpose. Thank you.
Here is my scenario: I use Default.aspx and Default1.aspx to open MyHome.aspx (the Home page of my application without any toolbar, menubar, etc.).

Default.aspx:

<script language="javascript" type="text/javascript">
window.onload = OpenWindow();
function OpenWindow(){
window.open('Default1.aspx','_self');
}
</script>

Default1.aspx:

<script language="javascript" type="text/javascript">
window.onload = OpenHomePage();
function OpenHomePage(){
window.open('MyHome.aspx','null','width=1012,height=733,toolbar=no, scrollbars=no,location=no,resizable=yes,status=no');
window.close();
}
</script>

Frank Lin





Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Anonnymous

Thank you for your suggestion. I don't understand why MS thinks that a close() command in javascript can be a security problem and add it to the list of the commands which needs privileges to execute. Our online business was completely different for sometimes until I found that customers with IE7 get a "strenge" confirmation when processing their credit card which is done by calling the payment processor in a new window. The new window supposed to close after the successfull proccess and redirect the customer to the "success" page in the opener window.

We can't use .hta files which needs a "run" confirmation when the customers pay their bills. I do wish that MS folks do not change this behavior which you recommended, cause this will lead to a complete reconstruction of our web-shop.





Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Achinth

Hi Paul,

Thanks for the great tip. The window closes with a prompt in IE7 now but now the prompt appears in IE6.

We need to add window.opener=top; to the close.html before calling window.close() for it to work in IE6 and IE7.

So, the final HTML will be

<html><body>
<script language="JavaScript">window.opener = top;window.close();</script>
</body></html>





Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Chandana Sanjeewa

Thanks for all u guys great work on this issue. Great job.




Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

IndustrialGroup

does anybody know why a script like:

<script language=¡±JavaScript¡± type=¡±text/JavaScript¡±>

var theHash = document.location.hash;

alert( theHash );
.....

</script>

displays the right values in ie6 and null in ie7






Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Prasanth

Hai dude,

Thanks for sharing this information that I was looking for..I checked it and is working fine...The confirmation message box has been suppressed !!!





Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Albrecht

Hi Paul and Achinth;

Your contributions helped a lot! Thank you.

Albrecht





Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

scottchu

I tried that, it doesn't even ask me to close window...



Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

scottchu

In my case, it doesn't work! the html is generated by an JSP, which, is forwarded to by another JSP. It doesn't even ask me to close window..@@

And at last, I made it by change code to 'top.opener=top; top.close()';





Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

unique_username

works for me in IE7

testpage.html foo=bar#baz

alerts... "#baz"




Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Anonymous

Paul and Achinth,

I'm glad to have found this thread. It works like a charm!

Thank you very much.




Re: Internet Explorer Web Development Prompting Users When Using window.close() In IE7

Snails

Hi Paul and Achinth;
window.open("close.htm"), did close the parent window,but the child window that launch the clickonce applicaiton could not be closed ,any good idea
the following is my sample .

var childwin = window.open("clickonce.application");
window.open("close.htm");
childwin.open("close.htm");

By the way

//Response.Write("<script>javascript:var w = window.open('clickonce.application','_blank');
w.opener=null;
w.open('','_self');
w.close();
window.open('','_self');
window.opener=null;
window.close();</script>");

works well in IE7 of xp sp2,but does not wok well in IE7 of Vista

Does any one know sth. about this

Thank you .