...

View Full Version : problems closing a window with some browsers



xbuddy
03-19-2004, 01:08 AM
I have a program that opens a window (called Start.htm) which opens a new window. The reason I need to do this is because the new window needs to be sized, stripped of the toolbar, etc. Once the new window is opened (which is less than a second), the "start" window closes automatically. Listed below is the command I'm using to close the "start" window.

The close command works great, except when I tried in on a older computer running Windows 98 (using IE). In this situation it would not close automatically, but would come up with a dialog box asking, "Do you want to close this window?"

Any ideas on how to get around this problem? Is there another close command that is more universal?

*******************************

onload = function()
{
opener = self;
self.close();
}

Harry
03-19-2004, 04:16 AM
Here is one I use. I give the opener window a name and then I am the owner of the window and it will let me close it without the dialogue box in MSIE.

<head><title>Index</title>

<script language="javascript">
function openSite(){
var wide=screen.width;
var high=screen.height;
var where_to;

switch(wide)
{
case 640:
switch(high)
{
case 480:
where_to='hr_page_one_640.php';
}
break;
case 800:
switch(high)
{
case 600:
where_to='hr_page_one_800.php';
}
break;
case 1024:
switch(high)
{
case 768:
where_to='hr_page_one_1024.php';
}
break;
case 1152:
switch(high)
{
case 864:
where_to='hr_page_one_1152.php';
}
break;
case 1280:
switch(high)
{
case 1024:
where_to='hr_page_one_1280.php';
}
break;
default:
where_to='hr_page_one_1024.php';
}

var mainwin = window.open(where_to,"mainwin", "");
window.opener='BrazilR0x';
window.close();
}
</script>

</head>

<body onload="openSite()">

</body>
</html>

glenngv
03-19-2004, 04:34 AM
Closing the main window without the consent of the user is considered rude. The reason that it works without the prompt is that it is a bug in the browsers. Therefore, don't ever rely on that exploit still working in the future when browser makers fix that bug.

JohnKrutsch
03-19-2004, 04:53 AM
I would agree that it is rude on the web but many people develop browser based applications that run purely on the client- side as an application of sorts. In these situations I have seen the need to do this.

glenngv
03-19-2004, 05:25 AM
But what's your ultimate purpose to do that? To hide the source code? :rolleyes:

JohnKrutsch
03-19-2004, 05:32 AM
When I use to do it it was because I wanted it to appear like an actual application rather than just a web page running locally.

xbuddy
03-19-2004, 03:35 PM
But what's your ultimate purpose to do that? To hide the source code?

______________________________________________

No, I'm not trying to hide the source code nor am I trying to be controlling or rude. I working on a stand alone program that will run off a CD. It will never be on the Internet. I'm not trying to "control" the other person's computer, I'm simply trying to find a practical solution to a problem I have run into.

This program will primarily be displayed on a projection screen in auditoriums. As a result, the aesthetics and appearance of the screen is very important. The two main issues I'm trying to address are:

-toolbar clutter
-Screen size

Toolbar clutter: Since the program is a stand-alone application not running on the Internet, the toolbar becomes clutter and a distraction. The toolbar would serve no purpose at all and it will only be a distraction to the audience. It would be nice to be able to open a window and have it's internal instructions turn off these functions. However, the only way I have found to do this is put these instructions in the "calling" window. That is the reason I need to open a window for a quick moment, issue a command to open a window without the toolbar, etc. and then close itself.


Screen size #1: Another problem I ran into is two fold. First, there are times when you open a window (like Excite.com) and it fills up the whole screen, and then (on the same computer and on the same day) you can open the same window and it only fills half the screen. I needed to find a way to resolve this problem. I have not found a "Maximize" command to prompt the window to automatically start at the full size.

Screen size #2: The other problem I ran into is the large number of screen resolutions being used. I had to find a way to open a window that will fill the whole screen every time. Once again, the only way I have been able to accomplish this is through opening a "starter" window which will open my final window.

So I'm back to my original issue. If there is a solution to the above problems, I'll be glad to use them. However, if there isn't, I need to be able to find a way to automatically close my starter window.

Thanks for your help. I would appreciate any input you can provide.

Roy Sinclair
03-19-2004, 03:47 PM
Originally posted by JohnKrutsch
When I use to do it it was because I wanted it to appear like an actual application rather than just a web page running locally.

Then rename the page to xxx..hta and then you can add some simple code which specifies exactly how the window should appear the very first time and not have to do this opening and closing windows stuff. Of course it only works with local pages but that doesn't sound like a problem in your case.

You also gain a raft of other capabilities that are normally locked out when you go this route so it really is the route to take.

http://www.microsoft.com/technet/archive/ie/evaluate/htmlapps.mspx

and

http://msdn.microsoft.com/workshop/author/hta/hta_node_entry.asp

should get you started.

xbuddy
03-19-2004, 05:19 PM
Thanks for your help. I'll try the suggestions



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum