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

The web page you are viewing is trying to close the window

Status
Not open for further replies.

adddeveloper

Programmer
Dec 16, 2006
43
US
I have a window that's opened via a hyperlink from a parent window.

If I try to close this "child" window with a simple self.close(), I get the prompt:

The web page you are viewing is trying to close the window

Here's my HEAD code:
<SCRIPT language="VBScript">
Sub Window_Onload
window.opener = "x"
End Sub
</SCRIPT>

In my BODY, I've got:
<INPUT type="button" value="Close Form"
onclick="self.close();" >
 
I don't know what that VBScript craziness is that you've posted, but this works fine:
Code:
[!]test.html[/!]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">

window.onload = function () {
   window.open("test2.html");
};

</script>
<style type="text/css"></style>
</head>
<body>
</body>
</html>

Code:
[!]test2.html[/!]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">


</script>
<style type="text/css"></style>
</head>
<body>
<input type="button" value="click me" onclick="self.close()" />
</body>
</html>

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Don't know what to tell you then, it worked for me.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
I don't think you can close a window without user agreement in all cases, will depend on the configuration of the client browser.

Cheers,
Dian
 
adam0101,

Tried this but still same as before with pop-up question to close the page (thanks for the suggestions though):

<HEAD>
<SCRIPT language="VBScript">
Sub Window_Onload
window.opener = "self;"
End Sub
</SCRIPT>
</HEAD>

..in body:
<INPUT type="button" value="Close" onclick="self.close();" >
 
I think they fixed that 'feature' in IE7 if that's what you're testing in.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Enable Apps
 
To:eek:p
[1] What you posted repeatedly, purported to be client-side vbs that I have no problem with, is not correctly done to begin with.
><INPUT type="button" value="Close" onclick="self.close();" >
[tt]<INPUT type="button" value="Close" [blue]language="vbscript"[/blue] onclick="self.close([highlight])"[/highlight] >[/tt]
[2] Also the assigning to window.opener="self;" look awkward, better plain and simple window.opener=self (no quotes, no semicolon).
 
Hello!

I just ended up using a DIV tag w/in the page via CSS.

I tested the page w/ both IE6 and 7.

Since we started off asking the user if they would or wouldn't like to perform a step, we took that out and simply presented them with the final form to fill out and a "Close" button at the top.

Thanks for all the help!
 
Adam, it depends on your browser settings. I have the IE7 settings set to prompt me, and I get the verification prompt every time regardless if I use the window.opener=self "trick".

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Hi there,

I am having the same problem.
Which settings do you need to change in IE7 in order to NOT get the "The web page you are viewing is trying to close" message?

In IE6 I used the Java script code as discussed in this thread but this does not appear to work for me in IE7. Can someone please help?

In IE6 I use the following code
------------------------------------

window.opener = self;
window.close;

------------------------------------

Thanks in advance!!!
 
djgann said:
Which settings do you need to change in IE7 in order to NOT get the "The web page you are viewing is trying to close" message?

dwarfthrower said:
I think they fixed that 'feature' in IE7

Basically your page shouldn't be able to close down the browser window. Aside from any popup windows your page launches, controlling the actual browser session should be left to the user. Thus you can take "fixing a feature" to read "closing down a security hole / user annoyance".

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Enable Apps
 
Thanks everyone for the input to my question.

After having a meeting yesterday with a lot of "big-wigs", they basically didn't even read the javascript I had on the page which flashes saying "Allow pop-ups for this site" in very big letter, along with a big help icon as to why to do so.

I just went to one of their desks, and they had pop-up blocker turned on, and it was a simply fix to allow for my site.

I've gone to doing the DIV tag route, since there is nothing really more I can do for the users to actually read instructions in order to make the application functional and friendly.

Lesson learned on my part!

Thanks again!
 
big-wigs" usually don't know anything, they just look the part. :)

<.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top