Solved

window.close function

Posted on 2004-10-01
7
795 Views
Last Modified: 2008-01-09
I have read many posts and still find no resolution to my problem as it relates to the window.close() and getting the popup window where the user must allow the window to close.  I also tried using the self.close() and had the same results. I have included the code below.

The ultimate goal is to create a "Launcher" page that will open a URL in a maximized window, and have NO title (not sure this is possible), toolbars, status bar or menu bars. After it launches the URL I need the parent / launcher window to close automatically.  This is going to be used in a Kiosk type environment yet I do not want the full screen affect that kiosk mode creates.  The code below works perfectly with the exception that it prompts the aggrivating "Do you wnat to close this window?" box and that the new window has the Title displayed along with Microsoft Internet Explorer across the top.  I realize this is due to a security problem and generic branding, but it will be used internally.

************  Code copy  ***************

 <html>

      <head>
            <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
            <title>Launcher</title>
            <csactionitem name="launch"></csactionitem>
                  <csactions>
                  <csaction name="launch" class="Open Window" type="onload" val0="http://blahblahblah" val1="_blank" val2="0" val3="0" val4="true" val5="true" val6="false" val7="false" val8="false" val9="false" val10="false">
            </csactions>
            <csscriptdict>
                  <script><!--
CSInit = new Array;
function CSScriptInit() {
if(typeof(skipPage) != "undefined") { if(skipPage) return; }
idxArray = new Array;
for(var i=0;i<CSInit.length;i++)
      idxArray[i] = i;
CSAction2(CSInit, idxArray);}
CSStopExecution = false;
function CSAction(array) {
      return CSAction2(CSAct, array);
}
function CSAction2(fct, array) {
      var result;
      for (var i=0;i<array.length;i++) {
            if(CSStopExecution) return false;
            var actArray = fct[array[i]];
            if(actArray == null) return false;
            var tempArray = new Array;
            for(var j=1;j<actArray.length;j++) {
                  if((actArray[j] != null) && (typeof(actArray[j]) == "object") && (actArray[j].length == 2)) {
                        if(actArray[j][0] == "VAR") {
                              tempArray[j] = CSStateArray[actArray[j][1]];
                        }
                        else {
                              if(actArray[j][0] == "ACT") {
                                    tempArray[j] = CSAction(new Array(new String(actArray[j][1])));
                              }
                        else
                              tempArray[j] = actArray[j];
                        }
                  }
                  else
                        tempArray[j] = actArray[j];
            }                  
            result = actArray[0](tempArray);
      }
      return result;
}
CSAct = new Object;

function CSOpenWindow(action) {
      var wf = "";      
      wf = wf + "width=" + action[3];
      wf = wf + ",height=" + action[4];
      wf = wf + ",resizable=" + (action[5] ? "yes" : "no");
      wf = wf + ",scrollbars=" + (action[6] ? "yes" : "no");
      wf = wf + ",menubar=" + (action[7] ? "yes" : "no");
      wf = wf + ",toolbar=" + (action[8] ? "yes" : "no");
      wf = wf + ",directories=" + (action[9] ? "yes" : "no");
      wf = wf + ",location=" + (action[10] ? "yes" : "no");
      wf = wf + ",status=" + (action[11] ? "yes" : "no");            
      window.open(action[1],action[2],wf);
}

// --></script>
            </csscriptdict>
            <csactiondict>
                  <script><!--
CSInit[CSInit.length] = new Array(CSOpenWindow,/*URL*/ 'http://blahblahblah','_blank',0,0,true,true,false,false,false,false,false);

// --></script>

            </csactiondict>
      </head>

      <body bgcolor="#ffffff" onload="CSScriptInit(); window.close(); return false">
            <p></p>

      </body>


</html>

************** End copy  ***********************

As you see I tried using "return false" but still get prompted.  I also tried self.close() and get the same results.

Details:

This will be a Short cut / html file on the desktop of a Windows XP Pro w/ srv pk1 PC, and the URL will be for a local network server.

How do I avoid the window and remove the text in the title area?

Could I do this easier through some sort of batch script or arguments in the short cut link?


TIA
0
Comment
Question by:colonytire
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:ewong_111
ID: 12203097
You can try to launch a blank window, and use the blank window to launch the "launcher" window:

<script language="javascript">
newwin = window.open('launcher.html');
function getgoing(url){
      newwin.close();
      window.location.href = url;
}
</script>

and use the launcher window to set up values in the first window and then ask the first window to close the launcher window..

<script language="javascript">
      window.opener.getgoing('http://www.yahoo.com');
</script>

Hope this helps..
0
 
LVL 10

Accepted Solution

by:
avidya earned 125 total points
ID: 12203271
Hi,

windows close only without userinterferance when they are opened with code.

A html on the desktop doesn't work, but a shortcut will
here is an example for IE, just replace yourpage.htm with your own:

"C:\Program Files\Internet Explorer\IEXPLORE.EXE" javascript:void(window.open('http://yourpage.htm',null,config='toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,directories=no,status=no'));
0
 
LVL 5

Author Comment

by:colonytire
ID: 12203470
OK, that got me close but it doesn't close the initial window. I am left with 2 windows.  The active / in front window is good., however I have a second window in the task bar and it's title is javascript:void....bla blah.  How do I get the initial window created from that shortcut to close?  I tired adding the window.close() to the end of your command sting but that takes me back to the popup window.

 
0
 
LVL 10

Expert Comment

by:avidya
ID: 12203882
oeps, sorry, just tought I made an error posting.
didn't know it was an security issue.

Cobal, please delete this comments and sorry again
0
 
LVL 5

Author Comment

by:colonytire
ID: 12204075
Sorry to have caused such a rucuss.  The end result is that it worked fine. I see the position of the admins for not wanting such posts.  This is being used internally and as the admin take full responsibility of it's use. Our end users may be holding the mouse but I control the content.

I will be awarding the points to Avidya. COBOL you may delete the entire question if need be.

Thank you all for helping.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now