Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Dec 2003
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problems closing a window with some browsers

    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();
    }

  • #2
    New Coder
    Join Date
    Jul 2003
    Location
    Houston, Texas
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>
    Beyond a critical point within a finite space, freedom diminishes as numbers increase. ...The human question is not how many can possibly survive within the system, but what kind of existence is possible for those who do survive."

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    But what's your ultimate purpose to do that? To hide the source code?

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.

  • #7
    New Coder
    Join Date
    Dec 2003
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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/arc.../htmlapps.mspx

    and

    http://msdn.microsoft.com/workshop/a...node_entry.asp

    should get you started.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #9
    New Coder
    Join Date
    Dec 2003
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks guys

    Thanks for your help. I'll try the suggestions


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •