设置open方法中的参数

发表于:2007-06-30来源:作者:点击数: 标签:
open method (window object)br Opens a new web browser window. br br 语法br [windowVar = ][window].open(quot;URLquot;, quot;windowNamequot;, [quot;windowFeaturesquot;])br br windowVar is the name of a new window. Use this variable when refer
open method (window object)<br>
Opens a new web browser window. <br>
<br>
语法<br>
[windowVar = ][window].open(&quot;URL&quot;, &quot;windowName&quot;, [&quot;windowFeatures&quot;])<br>
<br>
windowVar is the name of a new window. Use this variable when referring to a window@#s properties, methods, and containership. <br>
URL specifies the URL to open in the new window. See the location object for a description of the URL components. <br>
windowName is the window name to use in the TARGET attribute of a &lt;FORM&gt; or &lt;A&gt; tag. windowName can contain only alphanumeric or underscore (_) characters. <br>
windowFeatures is a comma-separated list of any of the following options and values: <br>
<br>
&nbsp;&nbsp;&nbsp;toolbar[=yes|no]|[=1|0]<br>
&nbsp;&nbsp;&nbsp;location[=yes|no]|[=1|0]<br>
&nbsp;&nbsp;&nbsp;directories[=yes|no]|[=1|0]<br>
&nbsp;&nbsp;&nbsp;status[=yes|no]|[=1|0]<br>
&nbsp;&nbsp;&nbsp;menubar[=yes|no]|[=1|0]<br>
&nbsp;&nbsp;&nbsp;scrollbars[=yes|no]|[=1|0]<br>
&nbsp;&nbsp;&nbsp;resizable[=yes|no]|[=1|0]<br>
&nbsp;&nbsp;&nbsp;width=pixels<br>
&nbsp;&nbsp;&nbsp;height=pixels<br>
<br>
You may use any subset of these options. Separate options with a comma. Do not put spaces between the options. <br>
<br>
pixels is a positive integer specifying the dimension in pixels. <br>
<br>
Method of<br>
window <br>
<br>
Description<br>
The open method opens a new web browser window on the client, similar to choosing New Web Browser from the File menu of the Navigator. The URL argument specifies the URL contained by the new window. If URL is an empty string, a new, empty window is created. <br>
<br>
In event handlers, you must specify window.open() instead of simply using open(). Due to the scoping of static objects in JavaScript, a call to open() without specifying an object name is equivalent to document.open(). <br>
<br>
windowFeatures is an optional, comma-separated list of options for the new window. The boolean windowFeatures options are set to true if they are specified without values, or as yes or 1. For example, open(&quot;&quot;, &quot;messageWindow&quot;, &quot;toolbar&quot;) and open(&quot;&quot;, &quot;messageWindow&quot;, &quot;toolbar=1&quot;) both set the toolbar option to true. If windowName does not specify an existing window and you do not specify windowFeatures, all boolean windowFeatures are true by default. If you specify any item in windowFeatures, all other Boolean windowFeatures are false unless you explicitly specify them. <br>
<br>
Following is a description of the windowFeatures: <br>
<br>
toolbar creates the standard Navigator toolbar, with buttons such as &quot;Back&quot; and &quot;Forward&quot;, if true <br>
location creates a Location entry field, if true <br>
directories creates the standard Navigator directory buttons, such as &quot;What@#s New&quot; and &quot;What@#s Cool&quot;, if true <br>
status creates the status bar at the bottom of the window, if true <br>
menubar creates the menu at the top of the window, if true <br>
scrollbars creates horizontal and vertical scrollbars when the document grows larger than the window dimensions, if true <br>
resizable allows a user to resize the window, if true <br>
width specifies the width of the window in pixels <br>
height specifies the height of the window in pixels <br>
例子<br>
In the following example, the windowOpener function opens a window and uses write methods to display a message: <br>
<br>
function windowOpener() {<br>
&nbsp;&nbsp;&nbsp;msgWindow=window.open(&quot;&quot;,&quot;displayWindow&quot;,&quot;menubar=yes&quot;)<br>
&nbsp;&nbsp;&nbsp;msgWindow.document.write<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&quot;&lt;HEAD&gt;&lt;TITLE&gt;Message window&lt;/TITLE&gt;&lt;/HEAD&gt;&quot;)<br>
&nbsp;&nbsp;&nbsp;msgWindow.document.write<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&quot;&lt;CENTER&gt;&lt;BIG&gt;&lt;B&gt;Hello, world!&lt;/B&gt;&lt;/BIG&gt;&lt;/CENTER&gt;&quot;)<br>
}<br>
<br>
The following is an onClick event handler that opens a new client window displaying the content specified in the file sesame.htm. The window opens with the specified option settings; all other options are false because they are not specified. <br>
<br>
&lt;FORM NAME=&quot;myform&quot;&gt;<br>
&lt;INPUT TYPE=&quot;button&quot; NAME=&quot;Button1&quot; VALUE=&quot;Open Sesame!&quot;<br>
&nbsp;&nbsp;&nbsp;onClick=&quot;window.open<br>
&nbsp;&nbsp;&nbsp;(@#sesame.htm@#, @#newWin@#, @#scrollbars=yes,status=yes,width=300,height=300@#)&quot;&gt;<br>
&lt;/FORM&gt;<br>
<br>
Notice the use of single quotes (@#) inside the onClick event handler. <br>

原文转自:http://www.ltesting.net