title: Cannot close the window in Mozilla and chrome?Gives scripting error?
body: <pre><code>  Please click &lt;a  onclick="self.close();"  href="#"&gt;here&lt;/a&gt; to close this window.
  </code></pre>
  
  <p>this is my code .</p>
  
  <p>when i submit in chrome and mozilla it shows the error.</p>
  
  <p>" script must not be allowed to close a window that was not opened by that same script."</p>
  
  <p>I tried with</p>
  
  <pre><code>  function quitBox(cmd)
    {   
    if (cmd=='quit')
    {
      open(location, '_self').close();
    }   
     return false;   
    }
  </code></pre>
  
  <p>but it does not work for me</p>
  
  <pre><code>     window.open('', '_parent', '');
           window.close();
  </code></pre>
  
  <p>and also with this script.</p>
  
  <p>how i close the tab on clicking the close tab like in explorer.
  I have opened the page using :</p>
  
  <pre><code>Response.Redirect("ApplyNow.aspx?Userid=" + Data.Encrypt(uId), false);
  </code></pre>
  
  <p>My html code is given below.</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /&gt;
      &lt;link href="_css/CalendarControl.css" rel="Stylesheet" /&gt;
      &lt;link href="_css/Apply.css" rel="Stylesheet" /&gt;
  
      &lt;script type="text/javascript" language="javascript" src="Scripts/NumberInWords.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript" language="javascript" src="Scripts/TotalFormat.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript" language="javascript" src="Scripts/FormValidations.js"&gt;&lt;/script&gt;
  
      &lt;link href="_css/CalendarControl.css" type="text/css" rel="stylesheet" /&gt;
      &lt;link href="Content/themes/metroblue/jquery-ui.css" rel="stylesheet" type="text/css" /&gt;
  
      &lt;script type="text/javascript" src="Scripts/jquery-1.9.0.min.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript" src="Scripts/jquery-1.9.0.min.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript" src="Scripts/jquery-ui-1.9.2.min.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript" language="javascript" src="Scripts/SubmitValidator.js"&gt;&lt;/script&gt;
  
      &lt;style type="text/css"&gt;
          #ui-datepicker-div td
          {
              font-size: 10px;
          }
      &lt;/style&gt;
  
      &lt;script type="text/javascript"&gt;
          function CloseWindow() {
              window.open('', '_parent', '');
              window.close();
          }
      &lt;/script&gt;
  
      &lt;/head&gt;
       &lt;body style="background: #6B9AAD url(_gfx/bgrd_tile.jpg) repeat-x fixed 0      0;" onload="if(IsCallOnLoad)  {SetDivVisibility();CallServerIndex_populateDealershipName();Details();};"&gt;
         &lt;form name="Form1" method="post" id="Form1"&gt;
         &lt;table style="width: 805px; height: 100%; background-color: #ffffff" align="center" cellpadding="0" cellspacing="0" border="0"&gt;
          &lt;tr id="trContent"&gt;
              &lt;td&gt;
                  &lt;table style="width: 100%" border="0"&gt;
                      &lt;tbody&gt;
                          &lt;tr&gt;
                              &lt;td style="width: 50%"&gt;
                                  First Name
                              &lt;/td&gt;
                              &lt;td style="width: 50%"&gt;
                                  &lt;span&gt;
                                      &lt;input style="width: 50%" id="FName" onclick="" onchange="" maxlength="100" /&gt;
                                  &lt;/span&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  Last Name
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;span&gt;
                                      &lt;input style="width: 50%" id="LName" onclick="" onchange="" maxlength="100" /&gt;
                                  &lt;/span&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  Address :
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;span&gt;
                                      &lt;input style="width: 50%" id="Address" onclick="" onchange="" maxlength="100" /&gt;
                                  &lt;/span&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  City :
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;span&gt;
                                      &lt;input style="width: 50%" id="City" onclick="" onchange="" maxlength="100" /&gt;
                                  &lt;/span&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  State :
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;span&gt;&lt;span&gt;
                                      &lt;select style="width: 51%" id="State" onclick="" onchange=""&gt;
                                          &lt;option selected="" value="NA"&gt;Select&lt;/option&gt;
                                      &lt;/select&gt;
                                  &lt;/span&gt;&lt;/span&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td style="text-align: center"&gt;
                                  &lt;input type="image" name="btnSubmit" id="btnSubmit" src="_gfx/submit.gif" onclick="if(CheckEnable()){var RsvalueCtrl = ValidateSectionControls();if(RsvalueCtrl==true){if(SetValue()){return true;}else{return false;}}else{return false;}}else{return false;};var SubmitConfirm= confirm('Do you want to Submit the form?');if (SubmitConfirm == false){return false};"
                                      style="border-style: None; border-width: 0px;" /&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                  &lt;/table&gt;
                  &lt;tr id="trMessage" style="display: none; height: 100%"&gt;
                      &lt;td style="width: 100%; height: 650px; text-align: center; vertical-align: top"&gt;
                          &lt;table style="width: 100%;" border="0"&gt;
                              &lt;tr style="vertical-align: middle"&gt;
                                  &lt;td style="vertical-align: middle; text-align: center; color: #660033; font-size: 20px;
                                      font-weight: bold"&gt;
                                      Thank You!!
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td style="vertical-align: middle; text-align: center;"&gt;
                                      Your application was&amp;nbsp;received successfully.
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td style="vertical-align: middle; text-align: center;"&gt;
                                      Please click &lt;a id="closeButton" onclick="self.close();" href="#"&gt;here&lt;/a&gt; to close
                                      this window.
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Is there any other solution.</p>