title: Pop up window self close function; close the site as well
body: <p>I have an Ajax call back function which call to a PHP function check the file modified time.
  I uses timer to execute it every 50 seconds.</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      setInterval("_checkPopUpUpdate()", 50000); //50 seconds
      &lt;/script&gt;
  
      function _checkPopUpUpdate()
      {
          var callback=new Object();
          callback.success=this.onExternalSuccess;
          callback.failure=this.onExternalFailure;
          YAHOO.util.Connect.asyncRequest('GET','/ci/ajaxCustom/ajaxCheckPopupUpdate',callback);
  };
  </code></pre>
  
  <p>The PHP function checks whether the file modified time has different between the first load session time</p>
  
  <pre><code>     $announcement_Popup_Path = HTMLROOT . $this-&gt;data['attrs']['file_path'];
    // Call model function
  
   if($this-&gt;data['attrs']['file_path'] !== '' &amp;&amp; file_exists($announcement_Popup_Path))
   {
       //When the announcement content load, it always stores the modified time into session
           $this-&gt;CI-&gt;load-&gt;model('custom/checkupdate_model');
             $firstloadTime = filemtime($announcement_Popup_Path);
       $this-&gt;CI-&gt;checkupdate_model-&gt;store_AnnouncementPopupSession($firstloadTime);
       //$this-&gt;data['Popup'] = file_get_contents($announcement_Popup_Path);
   }    
  
          function store_AnnouncementPopupSession ($popupTime)
      {
   $sessionPopupTime =array("annoucementPopUp"=&gt; $popupTime);
   $this-&gt;session-&gt;setSessionData($sessionPopupTime);
      }
  
       function announcement_pop()
      {
   $file_path='/euf/assets/announcements/pop_up_announcement.html';
   $announcement_Popup_Path = HTMLROOT . $file_path;
   if(file_exists($announcement_Popup_Path)) {
       $currentAnnouncementPopUpTime = filemtime($announcement_Popup_Path);
       $oldannouncementPopupTime = $this-&gt;session-&gt;getSessionData("annoucementPopUp");
  
       if($currentAnnouncementPopUpTime !=$oldannouncementPopupTime) {
    //comparing the content and update the time, when they are different,  send back update content
    $this-&gt;store_AnnouncementPopupSession($currentAnnouncementPopUpTime);
    //echo $currentAnnouncementPopUpTime;
    echo $file_path;
       }
       else {
    echo "no update";
       }
   }
      }
  </code></pre>
  
  <p>When the file modifed time has changed, it will return to ajax call back and grab the HTML content in my web server to Pop up an annoucement pop up window. </p>
  
  <pre><code>    function onExternalSuccess (o){
      if(o.responseText!==undefined)
      {
   var str=o.responseText;
  
  
       if(str !== 'no update') // Then pop up.
       {
    L=screen.width-200;
    T=screen.height;
    popup=window.open(str," ",'alwaysRaised=yes,status=no,toolbar=no,location=no,menubar=no,directories=no,resizable=no,scrollbars=no,height=150,width=364,left="+L+",top="+T');
    //popup=window.open(str,"",'alwaysRaised=yes,status=no,toolbar=no,location=no,menubar=no,directories=no,resizable=no,scrollbars=no,height=100,width=330');
    for (i=0;i&lt;200;i++)
    {
        T=T-1;
        popup.moveTo(L,T);
    }
       }
      }
  };
  </code></pre>
  
  <p>It works fine for Firefox and Chrome, however IE7 is a bit bugy, sometime the pop up does not come out. </p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
   &lt;title&gt;Internal alert&lt;/title&gt;
   &lt;link rel="stylesheet" type="text/css" href="/euf/assets/css/pop_up_ann.css" media="screen, projection" /&gt;
   &lt;script type="text/javascript"&gt;
      var howLong = 50000; //5 minutes, 1 seconds = 1000 milliseconds.
      t = null;
      function closeMe(){
      t = setTimeout("self.close()",howLong);
      }
        &lt;/script&gt;
      &lt;/head&gt;
      &lt;body onLoad="closeMe();self.focus();"&gt;
   &lt;div id="cs_popup"&gt;
          &lt;div class="popup_rounded-corner-top"&gt;
              &lt;div id="popup_ann"&gt;
                  &lt;div id="popup_ann_title"&gt;IE7 pop-up EMEA test close &lt;/div&gt;
                  &lt;div id="popup_ann_from"&gt; PLC team - 05/01/2011 at 12:10&lt;/div&gt;
              &lt;div id="popup_ann_content"&gt;
              Something has changed in the&lt;em&gt;&amp;quot;Alerts&amp;quot;&lt;/em&gt; section of S4S since your last visit.
              Make sure you go there as soon as you can to be informed about the current situation.
              &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="popup_rounded-corner-bottom"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The main problem i have here it is self-close function. It close my pop up window and the website as well. Any hints? Also, i am not sure whether my whole pop up annoucement logical structure is correct, is there anyway? thanks </p>