Opening a Pop-Up window using JavaScript

Popup windows are additional browser window opened from a web page.
The popups are opened programmatically using JavaScript.
JavaScript Popup windows are used widely for displaying advertisements.

To open a pop-up window on a button click, the code that can be referred is as below:

btnTest.Attributes.Add(“OnClick”, “window.open(‘/MySiteUrl/Pages/PopUp.aspx’, null,
‘height=900, width=1200,status= no, resizable= yes, scrollbars=yes, toolbar=no,
location=no,menubar=no ‘)”);

OR

void btnTest_Click(object sender, EventArgs e)
{
Page.Response.Write(“<script>window.open
 (‘/Pages/MyPopUpPage.aspx’,”,
‘height=600,width=900,status=no,toolbar=no,
menubar=no,left=180,top=210,
location=no,resizable=yes’);</script>”);
}

The different attributes/properties for the new pop up window
can be specified as well.

Advertisements

~ by Neha Sinha on February 1, 2008.

One Response to “Opening a Pop-Up window using JavaScript”

  1. Thank you for the blog. it was very helpful. I just want to give the title of the pop up window, a name. i mean i should give it a title..how to do that. can you help. Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: