How to Open a new Window using javascript ?

How to Open a new Window using javascript ?

 

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="FtpUpload.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="https://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" language="javascript">
    window.close=tt();
    function tt()
    {
        window.open(href="https://192.168.16.30/swlc" ,height="200", width="200");
        }
    </script>
</head>
<body bgcolor="linen">
    <form id="form1" runat="server">
</form>
</body>
</html>

 

IF YOU WANT TO OPEN NEW WINDOW FROM POSTBACK THEN HERE IS THE CODE ...

 

<form runat="server" id="form1">

   <asp:button id="button1" runat="server" onClick="button1_click" />
</form>
 
The "button1_click" event refers to a method that is run on the server. Here's how to add the JavaScript to create a popup, popunder, alert, or whatever else you need to do on the client side:
 
 
void page_load(object s, EventArgs e)
{
    if (!IsPostBack)
    {
       button1.Attributes.Add("onclick", "window.open('help.htm', '', '', 'height=200,width=400'");
       
       //button1.Attributes.Add("onclick", "alert('You clicked the button')");
       // or whatever
       //button1.Attributes.Add("onclick", "anyJavaScriptFunction");
    }
}