Web Analytics Made Easy -
StatCounter How to close window using JavaScript - CodingForum

Announcement

Collapse
No announcement yet.

How to close window using JavaScript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to close window using JavaScript

    l<script language="JavaScript" type="text/javascript">
    <!--
    function closeW()
    {
    window.opener = self;
    window.close();
    }
    // -->
    </script


    Hai

    i am using above code for closing window but it is not working..

  • #2
    JS window.close() only works on windows that have been opened by js and to do that you need to name the new window.
    A gotcha here is the name must be a single word.

    Use this
    Code:
    <script type="text/javascript">
       function popuponclick()
       {
          my_window = window.open("", "mywindow","status=1,width=350,height=150");
          my_window.document.write('Important information<br>about male pattern baldness');
       }
       function closepopup()
       {
          if(my_window.closed == false)
          {
             my_window.close ();
          }
          else
          {
             alert('Window already closed!');
          }
       }
    </script>
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

    Comment


    • #3
      This is a simple coding for close window


      <form>
      <input type=button value="Close Window" onClick="javascript:window.close();">
      </form>


      same script you can use for open window..

      Comment

      Working...
      X