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!

trying to close window w/o IE message 2

Status
Not open for further replies.

leTigre

Programmer
Mar 26, 2003
13
US
Hi guys-

I'm trying to close a window (index.html) that opens a pop up,homepage.html(the pop up contains my homepage, a frameset). The problem is I keep getting that IE message about "The webpage is trying to close a window..." Is there a simple way to avoid this, based on the code I already have?I want the pop up to load automatically and the index.html to close immediately without a button or text link to click on. Thanks so much for any help you can offer! Here's the code:


<html>

<head>
<meta http-equiv=&quot;Content-Language&quot; content=&quot;en-us&quot;>
<title>INDEX</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
window.close()

}

//-->
</script>
</head>

<body bgcolor=&quot;#009999&quot; text=&quot;#FFFFFF&quot; leftmargin=&quot;0&quot; topmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; onLoad=&quot;MM_openBrWindow('/Homepage.html','Homepage','toolbar=yes,location=yes,menubar=yes,scrollbars=yes,width=775,height=410, top=0, left=0')&quot; >
<a href=&quot;javascript:window.close();&quot;></a>
<p align=&quot;left&quot;> </p>
<p align=&quot;center&quot;> </p>
</body>

</html>
 
Why do you need two separate windows? Wouldn't it be easier to simply load your frameset into the original window?

Simple answer: Unless your script opened the window, you can't close it without the browser prompting the user.
 
actually, no there isn't... there are security limitations to javascript... and closing parent windows is one of them. I'm sure you can see why being able to do this COULD create problems.... sorry.

Later,
Greelmo
 
<a href=&quot;#&quot; onclick=&quot;opener=self;window.close();&quot;>close</a>

this works in a lot of browsers: IE5.5+, NS6+, and most Mozilla. I believe Mozilla Firebird does not allow it...and for good reason - it's a bug exploit! it technically should not work in any browser for security reasons.



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Jemminger--> I tried your script, but still receive the IE prompt.

The index page is totally unnecessary, I know, EXCEPT that it opens the frameset in a defined window (the user can't expand it and mess up the frames). The only way I knew how to do this was by starting with a dummy index that opens a &quot;pop up window&quot; where the frameset lives.

So, I guess the simplified question of all this is, can I open a window (index.htm) that has a predefined size and &quot;no resize&quot;? If so, then I can just dump the dummy window and load the frameset into that first window.

Suggestions for this new course of action? Thanks for all your responses- I really appreciate it!
 
Mess up the frames? Maybe you need to explore more features of frames such as percentages for row and column allocation. Maybe make a central set of frames of fixed size, surrounded by frames that can expand/contract because they contain only background. Maybe adopt a design that is congruent with the flexible, flowing rendering by browsers instead of a design that requires absolute control (because that way lies frustration).

And have you thought about the visitors to your no-nav, no-resize web page? They might feel that it is their browser window, not yours.

 
rac2,

At this point in the game, my frames are all at locked sizes and can't be changed. I see now the gross error of this, but as a newcomer to frames I didn't forsee such a problem way back in the planning stages. Now I know better, and hopefully someone else can learn from these mistakes.

I appreciate the crit, but I don't believe that a &quot;no resize frameset=no navigation web page&quot; automatically, especially since you haven't seen the webpage. From my experience, most folks don't even notice that they can't resize a window, especially if scrollbars are provided and enough space allocated to view graphics/text. This site is targeted at users with a 800x600 resolution, so the browser window will fill their entire screen. For those with higher resolutions, the window will appear in middle of their screens (stylistic choice).
 
I'm not sure if your question has been answered yet, but here is how I have handled your situation...

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function closeMe()
{
window.open(yourPage with info); window.opener=null;
window.close();
}
</SCRIPT>

<BODY onload=&quot;closeMe()&quot;></body>
 
Yeah!! It works, thanks soloa!!

One quick question-- it doesn't close the dummy index when I use Netscape (7.1). I still need to try it out on some older browsers, but any suggestions?
 
Hi, I only worry about and work with IE, but I just did a search for doing the same in Netscape, and came accross the following. It still works with IE, but I haven't checked it with Netsccape...

firstwindow = window.self;
firstwindow.opener = window.self;
firstwindow.close();

It said something about not working in Netscape 4.7, here's the actual link I found...

 
I will try that out, Soloa, and let you know...

FYI (for other newbies with similar problems):
In regards to the netscape vs. IE problem, here's an article I just found that explains the work around in plain english:


I had problems finding articles before b/c I wasn't exactly sure what to call this problem, but then I came across this language &quot;Close window unconditionally&quot; and that generated better search results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top