Search

Custom Search

Friday, March 7, 2008

Opening a new window without toolbars in C#

Here is window.open syntax:

winRef = window.open( URL, name [ , features [, replace ] ] )

The parameters URL, name, features, replace have the following meaning:

URL
String specifying the location of the Web page to be displayed in the new window. If you do not want to specify the location, pass an empty string as the URL (this may be the case when you are going to write some script-generated content to your new window).

name
String specifying the name of the new window. This name can be used in the same constructions as the frame name provided in the frame tag within a frameset .

features
An optional string parameter specifying the features of the new window. The features string may contain one or more feature=value pairs separated by commas.

replace
An optional boolean parameter. If true, the new location will replace the current page in the browser's navigation history. Note that some browsers will simply ignore this parameter.

The following features are available in most browsers:
toolbar=0/1
-Specifies whether to display the toolbar in the new window.
location=0/1
-Specifies whether to display the address line in the new window.
directories=0/1
-Specifies whether to display the Netscape directory buttons.
status=0/1
-Specifies whether to display the browser status bar.
menubar=0/1
-Specifies whether to display the browser menu bar.
scrollbars=0/1
-Specifies whether the new window should have scrollbars.
resizable=0/1
-Specifies whether the new window is resizable.
width=pixels
-Specifies the width of the new window.
height=pixels
-Specifies the height of the new window.
top=pixels
-Specifies the Y coordinate of the top left corner of the new window. (Not supported in version 3 browsers.)
left=pixels
-Specifies the X coordinate of the top left corner of the new window. (Not supported in version 3 browsers.)


Calling the window.open on serverside:

RegisterClientScriptBlock("Open Window","<script> window.open('sample.aspx','sample','toolbar=No, width=300, height=190, resizable=No, top=400, left=600')</script>");

To Create a page on the fly:

StringBuilder jscript = new StringBuilder();
jscript.append("<script>");
jscript.append("win=window.open('','login',");
jscript.append("'toolbar=No, width=300, height=190, resizable=No, top=400, left=600');");
jscript.append("win.response.write('<BODY>');");
jscript.append("win.response.write('this page is created on the fly!');");
jscript.append("win.response.write('</BODY>');");
jscript.append("</script>");
RegisterClientScriptBlock("Open Window", jsscript.ToString());


reference: http://www.javascripter.net/faq/openinga.htm

1 comment:

  1. First of all. Thanks very much for your useful post.

    I just came across your blog and wanted to drop you a note telling you how impressed I was with the

    information you have posted here.

    Please let me introduce you some info related to this post and I hope that it is useful for community.

    There is a good C# resource site, Have alook

    http://CSharpTalk.com

    Thanks again
    Rahul

    ReplyDelete

Adsense Banner