Pages

Saturday, December 22, 2012

How to Close Window Using Javascript


Window.Close() method is used for close window using JavaScript in HTML

Example :

<input type="button" value="Close" class="button" onclick="window.opener=null; window.close(); return false;">

HTML Example For Open Window and Close Window on Button Click Event:
Example :

<html>
<head>
    <script>

        function openWin() {
            myWindow = window.open("", "", "width=200,height=100");
            myWindow.document.write("<p>This is 'myWindow'</p>");
        }

        function closeWin() {
            myWindow.close();
        }
    </script>
</head>
<body>
    <input type="button" value="Open 'myWindow'" onclick="openWin()">
    <input type="button" value="Close 'myWindow'" onclick="closeWin()">
</body>
</html>


Window.Close() method is used for close window using JavaScript in ASP.NET
 
Example :
<asp:Button ID="Button2" runat="server" Text="Close" OnClientClick="javascript: window.close();"/>

  

#ASP.NET, #JAVASCRIPT,#CLOSE WINDOW
 

No comments:

ShareThis

Welcome

Welcome to Rajesh Prajapati, asp.net blog.
Here you can find some useful code and information about asp.net., c#, VB.net, SQL Server, Web Service, Web Designing etc