Solved

window.close function

Posted on 2004-10-01
7
801 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
archiving old posts 9 43
(URGENT) Help HTML and CSS Resizing Images 2 40
razorCMS: Change Menu Font 4 49
Stupid git question 2 64
Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

863 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

19 Experts available now in Live!

Get 1:1 Help Now