JavaScript Window Function Guide Name Window and Framework (Transfer)

xiaoxiao2021-03-06  41

When you create a file structure document, the tagname property defines the name of each frame, as follows:

In the example, the document contains 2 frames: LEFT and RIGHT. In the document Toolbar.html, the link code is as follows:

About US

feedback

Note that

tag also supports the target property, which defines the target window in response to the form. The tag indicates all the universal default target windows of all links in the document:

The above tag defines the target location of all elements in the page. The following HTML elements support Target properties: , , .

In practical applications, the element must appear between the Head tag of the document, before any elements that point to the external resource. If the tag is specified in the document, the link will no longer follow the default target position, but is clearly pointed to another different Target location:

Table of Contents

About US

feedback

As seen above, the first link Target is "_self" (with a downline), which means that the new document opens in the currently active window when clicking this link. The following table lists some special Target location identifiers in HTML:

Target meaning

_BLANK is loaded in a new empty window, and the new window is not named.

_PARENT is loaded in the direct parent window of the window where the link is located.

_Search is loaded on the browser search area, note that this feature is only available in Internet Explorer 5 or later.

_Self loads documents in the window where the link is located.

_Top loads a document in the top window.

Now we understand the frame name, below them work with the window. When defining the Target is "_blank", a new window will pop up. For example, if you want a link to open in a new window, use the following code:

A New Page New window is not named, in other words, it cannot be referenced by the Target attribute of other elements. But what happens when we use a standard Target name? Please see the definition below:

a new tip

In this case, we provide a special name for the new window. The name of the new window is "tip", so any link or form is defined as long as Target = "TIP" is defined, the page is loaded in the same window. If there is no frame or window to match the specified target, then click the link to open in a new window. Take a look at the example below:

ccidnet

technology world

Look at the result:

CCIDNET, technology world

Click on the first link to open the document in a new window. Click on the second link and will also generate a new window. If you click on the link again, the new window will still open. If you see, the link will have a new window every time you are clicked. Let us try again below:

ccidnet

Technology World

The effect is as follows:

CCIDNET, technology world

Click on the first link to generate a new window. Then click on the second link, the new document will appear in the window just opened. The new window defines a clear name called "main", so any link or form specified Target = "main" will be loaded in that window.

Name properties

With JavaScript, we can discover the name of the window through the window of the window (for IE3 , N2 ). Similarly, we can set the name attribute of a frame or window (for IE3 , N3 ). Let's take a look at the HTML document (Showname.html):

Display name </ title> </ head></p> <p><Body></p> <p><Script language = "javascript"></p> <p><! -</p> <p>Alert ('the name of this window is: "' window.name '");</p> <p>// -></p> <p></ Script></p> <p></ Body></p> <p></ Html></p> <p>Let's take a look at the link below:</p> <p><a href="showname.html" target="_blank"> a new window </a> <a href="showname.html" target="first"> first window </A></p> <p><a href="showname.html" target="second"> second window </a></p> <p><a href="showname.html" target="third"> third window </A></p> <p>Document showname.html contains a scriptor that is responsible for displaying the name of the window in an Alert dialog.</p> <p>The Name property belongs to the Window object. It can be used by any Window object, including a frame. For example, the following statement sets the name of a frame window:</p> <p>Parent.frames [1] .name = "right";</p> <p>When the framework is operated, it is very simple to access the different layers. If you want to see more details, please visit Window References.</p> <p>HTML cannot assign a name to the current window. That is, in the current page, it is impossible to set the name of the current window via HTML code. To achieve this, there is only one way to assign a value for the Window.Name property. Let's try it out, see the following code, it created a simple button, click the name of the current window after clicking:</p> <p><Form></p> <p><Input Type = "Button" value = "set name to mywin" onclick = "window.name = 'mywin'"></p> <p></ Form></p> <p>After clicking the button, the name of the current window changes to "mywin" unless otherwise, it will remain. We can include some links in other windows and define their Target location for myWin, which is target = "mywin".</p> <p>If you have already set the name of the current window to MyWin, the link will open in the current window. Below is the code in a new window:</p> <p><a href="http://www.docjs.com/" target="mywin"> Home </A></p> <p><a href="http://www.docjs.com/tips/" target="mywin"> Recent Tips </A></p> <p>For convenience, we give the source code of the button that can set the name of the current window "" "</p> <p><form></p> <p><Input OnClick = "Window.Name = ''" TYPE = Button value = "reset name" name = "button2"></p> <p></ form></p> <p>You have to pay attention, don't assign the same name to 2 different windows. If the 2 windows are assigned the same name, only one window is associated, and the other will be ignored.</p> <p>JavaScript Window Function Guide to open a new window</p> <p>January 21, 2001 11:11:13 Caidi Net Listening</p> <p>When you click on a simple link to open a new window, you don't have any control over the new window. The browser opens a new window with the default feature. In addition, you can't use JavaScript to reference the new window's Window object, so you can't manipulate the properties of the new window. Take a look at the JavaScript statement: window.open ("http://www.docjs.com/", "win");</p> <p>This statement opens a new window, and the page is displayed http://www.docjs.com/. The name of the new window is assigned to "WIN". The basic syntax of the Open () method of the Window object is:</p> <p>Window.Open (SURL, SNAME);</p> <p>Two parameters are optional. If you do not want to specify the URL or window name, you will use an empty string ("").</p> <p>SURL is a string that specifies the URL to display the document. If you do not specify a URL, an empty window is generated. Sname is the defined window name, which is used for <form> or <a> tag attribute. In Internet Explorer 5 and later, if this value is "_search", the SURL will be opened in the browser search area.</p> <p>What happens if you have the same parameter sname to perform a Window.Open () method, what happens? Like the window generated by HTML, if you define a name already existing window, the Open () method will simply use the existing window instead of opening a new. Take a look at the script programs below:</p> <p>WINDOW.OPEN ("http://www.javascript.com/", "win");</p> <p>WINDOW.OPEN ("http://www.docjs.com/", "win");</p> <p>Execute the above statement, the browser will open a new window name "WIN" and display the page at www.javascript.com. Article 2 statements Replace the current window content for the page www.docjs.com. The following statement produces two different windows to display their respective content:</p> <p>WINDOW.OPEN ("http://www.javascript.com/", "win1");</p> <p>WINDOW.OPEN ("http://www.docjs.com/", "win2");</p> <p>If you do not specify the name of the new window, the browser automatically generates a new window. This also applies to "_blank", but the empty string is another thing. There are several important differences for Internet Explorer and Navigator, as follows:</p> <p>WINDOW.OPEN ("http://www.cn.com/");</p> <p>WINDOW.OPEN ("http://www.usatoday.com/");</p> <p>Internet Explorer Navigator</p> <p>Open 2 different windows to open 2 different windows</p> <p>WINDOW.OPEN ("http://www.cnn.com/", "_blank");</p> <p>WINDOW.OPEN ("http://www.usatoday.com/", "_blank");</p> <p>Internet Explorer Navigator</p> <p>Open 2 different windows to open 2 different windows</p> <p>WINDOW.OPEN ("http://www.cn.com/", "");</p> <p>Window.Open ("http://www.usatoday.com/", ""); Internet Explorer Navigator</p> <p>Open 2 different windows Only open a window, name is empty ("")</p> <p>The following line will not be used, just listed. If you want a named window, give a name (not ""). If you don't want to name, you just don't specify this parameter, or use a special Target location "_blank".</p> <p>An important point of the open () method is that the open () method is almost always called in the form of Window.Open () (even if Window represents a global object so that it can be completely omitted. Since the Document object also has an Open () method, when we want to open a new window, specifying the Window object will be clear and necessary. In the event processing, you must specify Window.Open () without simply use Open (). Due to the scope limit of the static object in JavaScript, there is no option to Document.Open () without the OPEN () call of the specified object name. For example, when an event process of an HTML button occurs, the range contains button objects, form objects, document objects, and window objects. Thus, if one event processor references the Open () method, the identifier is aborted in the document object, and the event processor opens a new document instead of opening a new window.</p> <p>return value</p> <p>For the sake of reference sub-windows, the results of Window.Open () should be assigned to a variable. If the window is successfully created, Window.Open () returns a new window object, or returns NULL indicates that the creation fails (for example due to insufficient memory). If your script needs to reference the elements of the new window, the return value is very important. However, when the new window is opened, there is no "parent-child" relationship. Take a look at the following statement:</p> <p>Var reviewtips = window.open ("http://www.docjs.com/tips/", "TIPS");</p> <p>Here, we allocate a variable value called Recenttips. If you call the Window.Open () method in the function, you must omit the VAR keyword because the variable should be globally. Otherwise, the reference to Window is located in the local variable, and it cannot be accessed after the function is executed. The following statement displays the URL of the new window in an Alert dialog:</p> <p>Alert (Recenttips.Location.href);</p> <p>You can also change the URL of the new window by the following method:</p> <p>Recenttips.location.href = "http://www.usatoday.com/";</p> <p>In the previous section, you have seen how to open a new window using the HTML links and forms. We can name the window by specifying a Target property or assigning a value to the Name property of the Window object. But how can I tell the existing window through its HTML name? The answer is simple. If you perform a URL parameter with an empty string and a Window.Open () method where the window name is stored, the reference to this window will be returned. Take a look at the link code below: <a href="http://www.cnet.com/" target="news"> CNET </A></p> <p>When the following statement is executed, a reference to a new window is obtained:</p> <p>Var Latestnews = WINDOW.OPEN ("" ");</p> <p>Let's try again. Click this link CNET, but it is loaded, click the button below:</p> <p>This button actually retrieves the name of the window called "news" and modifies the URL of that window. Note that if you do not click on the link before clicking the button, a new, empty window is loaded (because the specified window name does not exist). Remember, no matter what the document in the window, the window always keeps its name. Below is this button related HTML and JavaScript code:</p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function Changeurl (WinName, NewURL) {</p> <p>Win = WINDOW.OPEN ("", winname);</p> <p>Win.Location.href = NewURL;</p> <p>}</p> <p>// -></p> <p></ Script></p> <p><Form></p> <p><Input Type = "Button" value = "load zdnet"</p> <p>Onclick = "Changeurl ('news', 'http://www.zdnet.com/')"></p> <p></ Form></p> <p>The previous section program indicates how to get a reference to a window. If you just want to change the URL of the window, you can also use the URL of the target page directly to call the Window.Open () method:</p> <p>Function Changeurl (WinName, NewURL) {</p> <p>Win = WINDOW.OPEN (NewURL, WinName);</p> <p>}</p> <p>In the following section, we will discuss how to customize the appearance of a new window.</p> <p>JavaScript Window Function Guide Customized New Window</p> <p>January 21, 2001 11: 11: 7 Said.com listening to wind compilation</p> <p>The basic syntax structure of the WINDOW.Open () method is:</p> <p>Window.Open (SURL, SNAME);</p> <p>However, you can customize new windows by using 2 additional parameters:</p> <p>Window.Open (SURL, SNAME [, SFEATURES] [, BREPLACE]);</p> <p>You can use the default feature by omitting these parameters. Let's take a look at the Breplace parameters, which is only supported by Internet Explorer: 4 and later. This parameter is only useless when the second parameter is named a already existing window. It is a boolean type value. If true, it means that the first parameter specified by the first parameter replaces the current window browsing location in history. If false, it means that a new project is created in the window of the window ( This is the default). Since this parameter is only supported by Microsoft's browser, it is not very useful. Let's take a look at the nature of the widely known JavaScript window. The 3nd parameter of the Open () method is a string that contains a comma-separated list (not to include any spaces). Let us look at their meaning before entering the available functional ocean. Here is an example:</p> <p>Win = WINDOW.OPEN ("http://www.docjs.com/", "DOCJS", "location = 1, menubar = 1, resizable = 1");</p> <p>This statement opens a variable size window with an address bar and a menu strip, while other features are turned off. For example, no status feature is specified, the new window has no status bar. Note that there are several other methods to define window features. Here are a command that is equivalent to the equivalent function of the previous statement:</p> <p>Win = WINDOW.OPEN ("http://www.docjs.com/", "DOCJS", "Location, MenuBar, ResIzable");</p> <p>Win = WINDOW.OPEN ("http://www.docjs.com/", "DOCJS", "Location = Yes, MenuBar = YES, Resizable = YES");</p> <p>Win = WINDOW.OPEN ("http://www.docjs.com/", "DOCJS", "Location, MenuBar = 1, Resizable = YES");</p> <p>Many features can be yes, or NO. For these features, you can use 1 replacement Yes, 0 instead of NO. If you want to activate a feature, you can also simply list the name of the feature in the SFEATURES string. If not listed, it means that the mask is shielded (except for Titlebar and HotKeys). The SFEATURES parameter is a list of comma-separated features, where no spaces or blank characters should be included. Each element in the list should contain the following format:</p> <p>Feature [= Value]</p> <p>Assigning a SFEATURES parameter an empty string has a great difference between all omitted this parameter. If you call open () without any parameters, all features are set to the default value. In other words, the browser will create a window that has a default width and height, standard menu, toolbar, and other browser features. If you use an empty string as a list of features that require functions, the browser will open a window, all of which is masked (except for Titlebar and HotKeys).</p> <p>The second parameter sname of the Window.open () method specifies the name of the window. If it is a name that already exists, the browser loads the specified URL (SURL) in that window. Therefore, if the SNAME specifies the existing window, the browser will ignore the defined list of features. Not all window features can be supported by all browsers. If the browser cannot identify the specified feature, it simply ignores it. Let's take a look at the definition of various window features in JavaScript:</p> <p>Alwayslowered InnerWidth Screeny</p> <p>Alwaysraiad Left Scrollbars</p> <p>ChannelMode location status</p> <p>Dependent MenuBar Titlebar</p> <p>Directories OuterWidth Toolbar</p> <p>Fullscreen OuterHeight Top</p> <p>Height MenuBar Width</p> <p>HotKeys Resizable Z-LOCK</p> <p>InnerHeight Screenx</p> <p>Alwayslowered</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>The specified window is always retained at the bottom of the stack. In other words, regardless of whether the new window is activated, it is always under other windows.</p> <p>WINDOW.OPEN ("alwayslowered.html", "_blank", "alwayslowered");</p> <p>Alwaysraised</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>The specified window is always retained on the top of the stack. In other words, no matter whether the new window is activated, it is always on other windows.</p> <p>WINDOW.OPEN ("Alwaysraiad.html", "_blank", "alwaysraised");</p> <p>ChannelMode</p> <p>Internet Explorer: Version 4 </p> <p>Navigator: Not supported</p> <p>Specifies whether to display the window according to the theater mode, and whether the channel area is displayed.</p> <p>WINDOW.OPEN ("ChannelMode.html", "_blank", "CHANELMODE");</p> <p>Dependent</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>Define whether the window becomes the dependent sub-window that is currently open. Relying on the window is when its parent window is turned off, it is immediately turned off. On the Windows platform, a dependent window does not display on the taskbar.</p> <p>WINDOW.OPEN ("Dependent.html", "_blank", "Dependent");</p> <p>Directories</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Specifies whether to display a directory button (such as a well-known "What's Cool" and "What's New" button). Internet Explorer references these directory buttons to the link toolbar, Navigator (version 4, and above) called personal toolbar.</p> <p>Window.Open ("Directories.html", "_blank", "Directories");</p> <p>Fullscreen</p> <p>Internet Explorer: Version 4 </p> <p>Navigator: Do not support</p> <p>Define whether to open the browser in full screen. Be careful to use full screen mode, because in this mode, the browser's title bar and menus are hidden, all you should provide a button or another visual clue to help users close this window. Of course, you can close the window using hotkeys Alt F4. Window.Open ("Fullscreen.html", "_blank", "fullscreen");</p> <p>HEIGHT</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Defining the height of the window document display area in pixel Pixel, the minimum value is 100. If only the height is defined, Internet Explorer uses a given height and the default width. For Navigator, this property will be ignored if Width or InnerWidth is specified at different times.</p> <p>WINDOW.OPEN ("Height.html", "_blank", "height = 200, width = 300");</p> <p>HotKeys</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>If you do not define (or 0), you block most of the hot keys in a new window without a menu bar. But safety, and exit hotkeys are still retained.</p> <p>WINDOW.OPEN ("HotKeys.html", "_blank", "HotKeys = 0, MenuBar = 0");</p> <p>InnerHeight</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>Defining the height of the window document display area in pixel Pixel, the minimum value is 100. In Navigator Release 4, this feature replaces Height, which is backward compatible. For Navigator, this property will be ignored if Width or InnerWidth is specified at different times.</p> <p>WINDOW.OPEN ("InnerHeight.html", "_blank", "InnerHeight = 200, InnerWidth = 300");</p> <p>Innerwidth</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>Defining the width of the window document display area in pixel Pixel, the minimum value is 100. In Navigator Version 4, this feature replaces width, which is compatible to keep backward. For Navigator, this property will be ignored if height or innerHeight is specified at different times.</p> <p>WINDOW.OPEN ("InnerWidth.html", "_blank", "InnerHeight = 200, InnerWidth = 300");</p> <p>Left</p> <p>Internet Explorer: Version 4 </p> <p>Navigator: Do not support</p> <p>Define the X left label of the window in pixels.</p> <p>WINDOW.OPEN ("Left.html", "_blank", "Left = 20");</p> <p>Location</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Define whether the text domain for the input URL input is displayed.</p> <p>WINDOW.OPEN ("Location.html", "_blank", "location"); menubar</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Define whether to display the menu bar (the menu bar is located at the top of the window, including "file" and "editing", etc.).</p> <p>WINDOW.OPEN ("MenuBar.html", "_blank", "Menubar");</p> <p>OuterHeight</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>The total height of the window (its external boundary) is defined in pixels, and the minimum value is more than 100, because the height of the window content area must be at least 100. If OuterWidth is not defined, Navigator will ignore this feature.</p> <p>WINDOW.OPEN ("OuterHeight.html", "_blank", "OuterHeight = 200, OuterWidth = 300");</p> <p>OuterWidth</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>The total width of the window (its external boundary) is defined in pixels, and the minimum value is more than 100, because the width of the window content area must be at least 100. If OuterHeight is not defined, Navigator will ignore this feature.</p> <p>WINDOW.OPEN ("OuterWidth.html", "_blank", "OuterHeight = 200, OuterWidth = 300");</p> <p>Resizable</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Define whether the window can be scaled through its boundary. Depending on the platform, the user may have other methods of changing the window size.</p> <p>WINDOW.OPEN ("Resizable.html", "_blank", "resizable");</p> <p>Screenx</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>Define the X coordinate of the window in pixels.</p> <p>WINDOW.OPEN ("Screenx.html", "_blank", "Screenx = 20");</p> <p>Screeny</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>Define the Y coordinates of the window in pixels.</p> <p>WINDOW.OPEN ("Screeny.html", "_blank", "Screeny = 20");</p> <p>Scrollbars</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Define whether to activate horizontal and vertical scroll bars.</p> <p>Window.open ("Scrollbars.html", "_blank", "scrollbars");</p> <p>STATUS</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Define whether the status bar is added at the lower part of the window.</p> <p>WINDOW.OPEN ("Status.html", "_blank", "status");</p> <p>Titlebar</p> <p>Internet Explorer: Version 5 Navigator: Version 4 </p> <p>Define if the title bar of the window is displayed. In Internet Explorer, this feature is shielded unless the caller is an HTML application or a trusted dialog.</p> <p>WINDOW.OPEN ("Titlebar.html", "_blank", "titlebar = 0");</p> <p>Toolbar</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Define if a browser is displayed (at the top of the window, including "back" and "forward").</p> <p>WINDOW.OPEN ("Toolbar.html", "_blank", "Toolbar");</p> <p>TOP</p> <p>Internet Explorer: Version 4 </p> <p>Navigator: Do not support</p> <p>Define the ordinate of the window in pixels.</p> <p>WINDOW.OPEN ("Top.html", "_blank", "TOP = 20");</p> <p>Width</p> <p>Internet Explorer: All versions</p> <p>Navigator: All versions</p> <p>Defining the width of the window document display area in pixel Pixel, the minimum value is 100. If you only define the width, Internet Explorer uses a given width and the default height. For Navigator, this property will be ignored if height or innerHeight is specified at different times.</p> <p>WINDOW.OPEN ("Width.html", "_blank", "height = 200, width = 300");</p> <p>Z-LOCK</p> <p>Internet Explorer: does not support</p> <p>Navigator: Version 4 </p> <p>Defining Windows is not floating in the stack when activated, that is, the new window is not on the other window when activated.</p> <p>WINDOW.OPEN ("Zlock.html", "_blank", "z-lock");</p> <p>JavaScript Window Function Guide Downtown Window Features</p> <p>January 21, 2001 11: 11: 4 Said.com listening to wind compilation</p> <p>In the previous section, we have fully contacted the window features provided by JavaScript. Many of these features are based on special browsers, that is, they cannot work in Internet Explorer and Navigator at the same time. In this section, we will explore a few interesting aspects and some useful techniques.</p> <p>Specify window scale</p> <p>We use parameters Height, Width, InnerHeight, and InnerWidth to define the scale of the new window. Internet Explorer supports Height and Width, Navigator uses InnerHeight and InnerWidth. Navigator also supports OuterHeight and OuterWidth feature, which specifies the scale of the peripheral boundary of the window, the peripheral boundary including the title bar, scroll bar, and other operating system elements. In Internet Explorer, we use Height, Width, InnerHeight, and InnerWidth. Each browser will ignore other features, so when you create a new window, you can define all four.</p> <p>Window.open ("Dimensions.html", "_blank", "Height = 150, InnerHeight = 150, Width = 200, InnerWidth = 200"); if there is two browsers on your machine, you can compare JavaScript Different window scale features.</p> <p>Open a full screen window</p> <p>Internet Explorer supports the FullScreen property and uses it to create a window overwriting full screen without having to consider the actual size of the display. Take a look at the example below:</p> <p><Script language = "javascript"></p> <p><! -</p> <p>Var str = "left = 0, screenx = 0, TOP = 0, Screeny = 0";</p> <p>IF (window.screen) {</p> <p>VAR AH = Screen.availHeight - 30;</p> <p>VAR AW = Screen.availsWidth - 10;</p> <p>Str = ", height =" ah;</p> <p>Str = ", innerHeight =" AH;</p> <p>Str = ", width =" AW;</p> <p>Str = ", innerwidth =" AW;</p> <p>} else {</p> <p>Str = ", resizable"; // so the user can resize the window manually</p> <p>}</p> <p>Function launchfull (URL, NAME) {</p> <p>Return window.open (URL, NAME, STR);</p> <p>}</p> <p>VAR WIN = launchfull ("ful1.html", "full");</p> <p>// -></p> <p></ Script></p> <p>Let us see how it works. First, we assign a initial value to the global variable STR, which specifies the new window located on the upper left corner of the screen. Don't worry about this string, this section will explain its meaning. The next statement checks if the browser supports the Screen object. If we do not support, we use the Resizable feature to change the size of the new window manually, and finally adapt to the entire screen. But if the browser is supporting the Screen object, you can make full use of Screen.vavilHeight and Screen.vavilWidth to determine the height and width of the working area on the system screen, including any system elements, such as the taskbar. Since Height, Width, InnerHeight, and InnerWidth cannot accurately describe the window boundary, you must subtract the value of the probably pixel.</p> <p>If you want to make full use of the browser's Fullscreen feature, just add the following script:</p> <p>Var str = "Left = 0, Screenx = 0, TOP = 0, Screeny = 0, Fullscreen";</p> <p>We don't need to check if the browser is Internet Explorer, because after the FullScreen feature is defined, other features are ignored.</p> <p>Define window coordinates</p> <p>We will use Left, Top, Screenx and Screeny parameters to specify the coordinates of the new window. Internet Explorer supports LEFT and TOP, Navigator uses Screenx and Screeny.</p> <p>Window.open ("http://www.docjs.com/", "_blank", "left = 20, screenx = 20, top = 40, screeny = 40"); Remember, Left should always be with Screenx Definition, TOP is defined with Screeny. If you have used these features, you will find that Navigator also supports LEFT and TOP. However, this is an unapproved operation, so you don't rely on this (because the future Navigator version may no longer support it). Moreover, if different values ​​are specified for LEFT and Screenx, the Navigator will use the value assigned to Screenx. Similarly, if Screeny is specified, Navigator will ignore TOP.</p> <p>Remember that these features are in pixels and are based on the top left corner of the screen. Even if you call the Window.Open () method in the frame, the specified value is still based on the border of the screen.</p> <p>Open a home window</p> <p>Now you know how to place a new window, add some algorithms below. The following script opens a hidden window:</p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function LaunchCenter (URL, Name, Height, Width) {</p> <p>Var str = "Height =" Height ", InnerHeight =" Height;</p> <p>Str = ", width =" width ", innerwidth =" width;</p> <p>IF (window.screen) {</p> <p>VAR AH = Screen.availHeight - 30;</p> <p>VAR AW = Screen.availsWidth - 10;</p> <p>VAR XC = (AW - width) / 2;</p> <p>VAR YC = (AH - Height) / 2;</p> <p>Str = ", left =" xc ", screenx =" XC;</p> <p>Str = ", TOP =" YC ", Screeny =" YC;</p> <p>}</p> <p>Return window.open (URL, NAME, STR);</p> <p>}</p> <p>Var win = launchcenter ('Center.html', 'Center', 220, 440);</p> <p>// -></p> <p></ Script></p> <p>This script is very similar to a script program for full screen windows. It uses the Screen.availHeight and Screen.availWidth properties, while adding the expected size of the new window, eventually calculating the exact location in the upper left corner of the window. If you are difficult to understand (aw-width) / 2, please see the following calculation:</p> <p>(AW / 2) - (width / 2)</p> <p>As you can see, they are the same, that is, from the center of the screen minus the width of the window width. The same algorithm is applied to the vertical coordinates of the window.</p> <p>Backward compatible link</p> <p>When we write a scriptor, consider those users who cannot use JavaScript, this often occurs when the user masks the JavaScript function in the browser. When this happens, we should still load a window using HTML. Take a look at the link below: <a href="http://www.docjs.com/" target="win"> DOC JavaScript </A></p> <p>This opens a window named WIN where the defined URL is loaded. The following link uses JavaScript to complete the same purpose:</p> <p><a href="javascript :void(Window.Open ('Http://www.docjs.com/','win','status') ""> Doc JavaScript </A></p> <p>JavaScript-based link creates a simple window, there is a status bar, but does not include other default elements (such as toolbars). However, the window in front of the HTML link is a default browser window. The two methods achieve the same purpose. Using JavaScript, we can control the appearance of the new window, but if the browser does not support JavaScript, this link is useless. So we merge these links:</p> <p><A href = "http://www.docjs.com/" Target = "WIN" onclick = "Window.Open ('http://www.docjs.com/', 'win', 'status'); Return False> DOC JavaScript </A></p> <p>If JavaScript is activated, before the URL defined by the HREF property is loaded, the browser executes the ONCLICK Event Handler. Since this event handler returns false, the browser will ignore the HREF attribute, as if the user does not click on the link at all. In fact, the statement RETURN FALSE has simply suspended "click". If the browser does not support JavaScript, then the OnClick event handler is not running, so, like other HTML links, the specified URL is loaded.</p> <p>JavaScript Window Function Guide Check if a window exists</p> <p>January 21, 2001 11: 11: 1 Said.com listening wind compilation</p> <p>When you create a new window, it is important to assign a variable to the return value of the Open () method. For example, the following statement creates a new window, then close it immediately:</p> <p>Win = WINDOW.OPEN ("http://www.docjs.com/", "js");</p> <p>Win.Close ();</p> <p>WINDOW object</p> <p>Each browser window corresponds to a clear Window object, so when you want to reference the current window, you should use the Window object. The following statement sets the URL of the current window:</p> <p>Window.location.href = "http://www.docjs.com/";</p> <p>When you place such a statement in the script, you don't need to specify a Window object, because the existence of the current window is default:</p> <p>Location.href = "http://www.docjs.com/";</p> <p>Note that Self is equivalent to Window, so self.close () is actually equal to Window.Close (). When you want to manipulate a window, you must confirm that it exists. When a variable is defined for the Window.open () method, it is defined as global variables and set to NULL. Remember, the Open () method returns the Window object of the new window. Here is an example:</p> <p>Var win = NULL;</p> <p>Function launchWindow () {</p> <p>Win = window.open ();</p> <p>// statements That Refer to the New window Go Here</p> <p>}</p> <p>If you want to perform an action on the new window, you should first check if the variable WIN is NULL:</p> <p>// if Win EXISTS, Move The Window</p> <p>IF (win) win.moveto (0, 0);</p> <p>Note that NULL is equal to FALSE, and any other legal object is equivalent to TRUE. If Win is equal to TRUE, you know it is not null, which means that the new window is successfully created.</p> <p>Open "attribute"</p> <p>Now you know the browser actually created a new window. But is it still existing? It is not necessary. You need to confirm that the available window does have a real Window object. Since each Window object corresponds to an Open () method, you can check this method through object probing:</p> <p>// If win.open exists, on the mobile window</p> <p>IF (win.open) win.moveto (0, 0);</p> <p>Variable WIN control window's Window object, so Win.Open corresponds to the Window.Open method of Window. Note that the conditional expression is a function reference, not a function call. Unless you confirm that Win exists, you should not try to estimate Win.Open. The following statement describes the correct implementation method:</p> <p>// if Win and win.open exist, Move the window</p> <p>IF (win && win.open) win.moveto (0, 0);</p> <p>Since && is a short operation symbol, if the first parameter (win) corresponds to true, the result depends on the second value. If the second parameter is false, the entire expression result is False. This is a very important behavior, because if Win does not exist, the expression Win.Open will generate an error.</p> <p>Closed attribute</p> <p>Due to the first version of JavaScript, the browser window is a very difficult problem. For example, some methods of a Window object, such as Close (), can be executed even when the window has been turned off, while others cannot (such as MoveTo ()). But the situation will be worse. Internet Explorer and Navigator often have different behaviors. Moreover, the results of predicting a certain operation are often very difficult, even if you have done similar attempts. We will tell you how to overcome these difficulties, the method is to introduce a statement that can be applied in a cross browser, which will check if a given window is opened.</p> <p>The Window.closed property is a Boolean type value that defines whether the window has been closed. When the window is turned off, the Window object still exists, and its closed property has been set to True.</p> <p>Using Closed to determine whether the open window and the window that can still be referenced (from the value returned from the window.open method) is still open. When the window is turned off, you should not try to manipulate it. Because Window.closed is only supported by Internet Explorer 4, Navigator 3, and you should pay attention to the previous version issues. We will use the following code: // if Win and win.open exist, and win.closed isn't true, move the window</p> <p>IF (Win & & Win.open &&! Win.Closed) Win.Moveto (0, 0);</p> <p>Internet Explorer 3 and Navigator 2 do not support Closed methods, so it is equally worth FALSE in the Boolean expression (like other non-existing properties, such as Window.Tomershiran).</p> <p>JavaScript Window Function Guide Close window</p> <p>January 21, 2001 11:10:59 Said.com listening wind compilation</p> <p>When you create a new window, allocate the return value of the Open () method to a variable is very important. For example, the following statement is to create a new window and close it immediately:</p> <p>Win = WINDOW.OPEN ("http://www.docjs.com/", "js");</p> <p>Win.Close ();</p> <p>Each browser window is clearly written with a Window object, so when you want to reference the current window, you should use the Window object. The following statement sets the URL of the current window:</p> <p>Window.location.href = "http://www.docjs.com/";</p> <p>When you place such a statement in the script, you don't need to specify a Window object, because the existence of the current window is default:</p> <p>Location.href = "http://www.docjs.com/";</p> <p>Note that Self is equivalent to Window, so self.close () is actually equal to Window.Close ().</p> <p>Window.location.href = "http://www.docjs.com/";</p> <p>close the window</p> <p>Window.close () Turn off the specified browser window. If the close () function is called without a window reference, JavaScript turns off the current window. In an event handler, you must specify Window.Close () without using Close (). Due to the scope of JavaScript total static object, a close () call without object name is equivalent to document.close ().</p> <p>If you perform a close () method to close a window that is not opened by the script, a confirmation dialog will have a confirmation dialog to select whether to close the window. If there is only a record in the historical list, the dialog box will not appear in the Navigator. However, if you use Close () to exit the last running browser instance, the confirmation dialog will appear. See the dialog box that appears in the 2-type browser looks like:</p> <p>Click on the link below to open a new window, where the content is TryClose.html:</p> <p>Launch Window (with JavaScript) launch window (with HTML)</p> <p>The first link uses JavaScript's Window.Open () method to open a window, and the second link simply uses the target attribute to achieve the same purpose:</p> <p><a href="javascript:void (Window.open('tryclose.html')"> launch window (with javascript) </A> <br></p> <p><a href="tryclose.html" target="_blank"> launch window (with html) </a></p> <p>Page TryClose.html Displays a button, it is responsible for performing a window.close () method:</p> <p><Form> <input type = "button" value = "close window" onclick = "Window.close ()"> </ form></p> <p>When you click on the first link to open a new window, the browser "remember" it is generated by a scriptor. So, when you click on the button, the new window does not have to confirm that the operation is turned off. The second link is another thing, it does not use any JavaScript to open a new window, when you click the button, Internet Explorer will display a confirmation dialog. However, Navigator immediately closes this window because the new window does not have any documents in the session history.</p> <p>JavaScript allows you to use a script in other windows to close another window.</p> <p>Click to close the window</p> <p>Many standard applications have an About dialog that is turned off when the user clicks on the mouse anywhere. The following effects are implemented using JavaScript on the window. First, see if you open the new window:</p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function launchabout () {</p> <p>About = WINDOW.OPEN ("About.html", "About", "Height = 75, Width = 250");</p> <p>Return False;</p> <p>}</p> <p>// -></p> <p></ Script></p> <p><a href="about.html" onclick="Return Launchabout()"> About </A></p> <p>After clicking the link, generate a new window. Then, you can click anywhere, turn off the window. Add the following script to the Head area of ​​the file About.html:</p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function closewin () {</p> <p>WINDOW.CLOSE ();</p> <p>}</p> <p>IF (Window.event) Document.captureevents (Event.onclick);</p> <p>Document.onclick = closewin;</p> <p>// -></p> <p></ Script></p> <p>Dependency window</p> <p>The dependency feature of the window defines whether the window should be a dependent sub-window for a current window. Relying on the window is when its parent window is turned off, it is immediately turned off. The Dependent feature is only supported in Navigator 4 and the above version. However, we can use a small JavaScript program to handle cross browsers. Let us use the following functions to open a dependency window: function openDep () {</p> <p>Win = WINDOW.OPEN ("Depwin.html", "DEP", "Height = 200, Width = 400");</p> <p>}</p> <p>If the current window is turned off, or when you transfer a new URL, we will use the ONUNLOAD event handler to close the dependency window:</p> <p><Body onunload = "closedDep ()"></p> <p>Note that the current document is uninstalled, the new window will turn off, even if the current window is still open. Below is the code of the ClosedEP () function:</p> <p>Function closed () {</p> <p>IF (Win & & Win.open &&! Win.Closed) Win.Close ();</p> <p>}</p> <p>Note that before trying to close, we must check if the window exists.</p> <p>JavaScript Window Function Guide Control Window</p> <p>January 21, 2001 11:10:57 Said.com listening wind compilation</p> <p>Once you get the variable indicating the window, you can manipulate it through a variety of ways. In the previous introduction, we discussed the close () method:</p> <p>Win = WINDOW.OPEN ("http://www.docjs.com/", "js");</p> <p>Win.Close ();</p> <p>JavaScript provides many methods and properties, we can use them to control the window.</p> <p>Move, scroll, change the size</p> <p>The following methods (N4 , IE4 ) are responsible for the movement, scrolling, and size change operations of a certain window:</p> <p>/ / Mobile window The screen position to the specified offset x, y (absolutely move)</p> <p>Window.Moveto (ix, i)</p> <p>/ / The screen position of the window to the specified offset x, y (relative movement)</p> <p>Window.Moveby (ix, i)</p> <p>/ / Scroll the screen position to the specified offset x, y (absolutely scrolling)</p> <p>Window.Scrollto (IX, IY)</p> <p>/ / Scroll the screen position to the specified offset x, y (relative scrolling)</p> <p>Window.Scrollby (ix, i)</p> <p>/ / Change the window size to the specified height and width (absolute change size)</p> <p>WINDOW.Resizeto (iWidth, Iheight)</p> <p>// Change the window size to the specified height and width (relative change)</p> <p>WINDOW.Resizeby (IX, IY)</p> <p>Note that these methods are Window objects, so they are intelligent in the current window or other window that can be referenced. If you want to dynamically set the location and size of the window, you can use the Move and Resize methods after the window is created.</p> <p>Note that it is impossible to control a window containing another server page.</p> <p>Maximize windows</p> <p>We now tell how to make a button to maximize the window after clicking.</p> <p>Let's take a look at the HTML and JavaScript code about this button:</p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function maximizewin () {</p> <p>IF (window.screen) {</p> <p>VAR AW = Screen.availswidth; var Ah = Screen.availheight;</p> <p>Window.moveto (0, 0);</p> <p>WINDOW.RESizeto (AW, AH);</p> <p>}</p> <p>}</p> <p>// -></p> <p></ Script></p> <p><Form> <input type = "button" value = "maximize" onclick = "maximizewin ()"> </ form></p> <p>Note that the ResizTo () method references the size of the entire window.</p> <p>A suspended advertisement</p> <p>On the website, through the mobile ad window, you can attract the attention of the browser. We can implement the effect of moving the window left and right by calling the following functions:</p> <p>Function Makead () {</p> <p>WINDOW.OPEN ("adpage.html", "ad", "width = 468, innerwidth = 468, height = 80, innerHeight = 80, Left = 0, TOP = 0");</p> <p>}</p> <p>Below is the code of page adpage.html:</p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function startad () {</p> <p>IF (window.screen) {</p> <p>POS = 0;</p> <p>AW = screen.availwidth;</p> <p>Window.moveto (POS, 0);</p> <p>Timerid = setInterval ("MoveAd ()", 50);</p> <p>}</p> <p>}</p> <p>Function movead () {</p> <p>IF (POS <= 0) INC = 5;</p> <p>// 5 - SO it Doesn't pass the right Edge</p> <p>// 10 - Accounts for the window chrome</p> <p>IF (POS 468 10 5> AW) INC = -5;</p> <p>POS = Inc;</p> <p>Window.moveto (POS, 0);</p> <p>}</p> <p>Window.onload = Startad;</p> <p>// -></p> <p></ Script></p> <p>When the page adpage.html is loaded, the function startAd () is executed. If the user's browser supports the Window.Screen object, the window can move because we need to use Window.Screen to calculate the width of the screen. The window slides on the upper boundary of the screen, from the upper left corner (POS = 0) until the upper right corner.</p> <p>By built-in setInterval () function, 5 pixels are moved every 50 milliseconds. If you click the "STOP" button, you will do the following statement:</p> <p>ClearInterVal (Timerid);</p> <p>Vibrating window</p> <p>As you can see, Move methods can help you attract users' attention. If you want visitors more shocking, you may want to add the following effect:</p> <p><Script language = "javascript1.2"></p> <p><! -</p> <p>VAR quakeid = 0;</p> <p>Var Totalx = 0;</p> <p>Var Totaly = 0;</p> <p>// Max Pixels in Each Movement</p> <p>VAR maxshift = 10;</p> <p>// min Movements in each quakevar minjumps = 10;</p> <p>// max movements in Each Quake</p> <p>Var maxjumps = 40;</p> <p>// min MilliseConds Between Two Quakes</p> <p>VAR minbetweenquakes = 1000;</p> <p>// Max Milliseconds Between Two Quakes</p> <p>Var MaxbetWeenquakes = 4000;</p> <p>Function jump () {// -maxshift to maxshift</p> <p>With (Math)</p> <p>Return (Maxshift 1 - CEIL (Random () * (MAXSHIFT * 2 1)));</p> <p>}</p> <p>Function winshake () {</p> <p>For (var i = 0; i <(mines.random ()); i ) {</p> <p>Dx = jump ();</p> <p>DY = jump ();</p> <p>Window.Moveby (DX, DY);</p> <p>TotalX - = DX;</p> <p>Totaly - = DY;</p> <p>}</p> <p>Window.Moveby (Totalx, Totaly);</p> <p>Totalx = 0;</p> <p>Totaly = 0;</p> <p>Quakeid = setTimeout ("Winshake ()", Math.ceil (Math.random () *</p> <p>(MaxBetWeenquakes - MinbetWeenquakes)) minbetweenquakes;</p> <p>}</p> <p>WinDow.onload = Winshake;</p> <p>// -></p> <p></ Script></p> <p>This script program produces a series of seismic effects. When the page is reproduced (Window.onLoad), it will begin to generate an effect.</p> <p>The jump () method returns a random integer from -maxshift to maxshift. The following code segment is responsible for a single vibration:</p> <p>For (var i = 0; i <(mines.random ()); i ) {</p> <p>Dx = jump ();</p> <p>DY = jump ();</p> <p>Window.Moveby (DX, DY);</p> <p>TotalX - = DX;</p> <p>Totaly - = DY;</p> <p>}</p> <p>Since we have no way to learn the initial position of the window, we must track the dimensions after each position adjustment. The value of the window is maintained relative to the initial position in the TotalX and Totaly variables. When the vibration is completed, the window moves back to the initial position.</p> <p>Window.Moveby (Totalx, Totaly);</p> <p>Totalx = 0;</p> <p>Totaly = 0;</p> <p>After an arbitrary location is suspended, the WinsHake () function is called again:</p> <p>Quakeid = setTimeout ("Winshake ()", Math.ceil (Math.random () *</p> <p>(MaxBetWeenquakes - MinbetWeenquakes)) minbetweenquakes;</p> <p>JavaScript Window Function Guide Writes in Window</p> <p>January 21, 2001 11:10:54 CCID NET</p> <p>Window.Open () method Opens a new window, open a new document in which write content can be written in Write () or WriteLn () method, its syntax is: onewdoc = document.open (SmimeType , SREPLACE]);</p> <p>Sminalype is a string that defines the MIME type. Navigator supports several different MIME types, but Internet Explorer only supports "text / html". The SMINTYPE parameter is optional. The second parameter is also a string, which defines whether the new document written is to replace the location of the current document in the history. If you want to replace the replacement, use the string "Replace".</p> <p>"Replace" is basically used to have a window with an empty document or an "About: Blank" URL. When "Replace" is defined, the Write () method can create HTML content in this window and replace the location of the current URL in the history. If "Replace" is not defined, the established HTML has its own historical position, and the user can click the back button until it is air.</p> <p>Take a look at the script block below:</p> <p>VAR OnewDoc = Document.Open ("Text / Html", "Replace");</p> <p>Var smarkup = "<html> <head> <title> new document </ title> </ head>";</p> <p>Smarkup = "<body> hello, world! <br> <a href='Write.html'> Return </a> </ body> </ html>";</p> <p>OnewDoc.write (smarkup);</p> <p>Onewdoc.close ();</p> <p>As you can see, we contain a link in the new document, so you can return this page. If you click on the back button of the browser, the browser returns to the page before this page. Because we used the "Replace" parameter, the new document (written) replaced the location of the current document in the history, so the back button will not return to the current page (including the page containing the scriptor). The following button performs the same scriptor, but no "replace" parameter, so you can return to this page by clicking the back button of the browser.</p> <p>The following is the source code for this button:</p> <p><script language = javaScript></p> <p><! -</p> <p>Function WriteDocBack () {</p> <p>VAR OnewDoc = Document.Open ("text / html");</p> <p>Var smarkup = "<html> <head> <title> new document </ title> </ head>";</p> <p>Smarkup = "<body> hello, world! </ body> </ html>";</p> <p>OnewDoc.write (smarkup);</p> <p>Onewdoc.close ();</p> <p>}</p> <p>// -></p> <p></ script></p> <p><form> <input onclick = write = "write document" name = "button2"> </ form> As you can see in the 2 examples above, the last statement is turned off the output stream:</p> <p>Onewdoc.close ();</p> <p>Typically, the Document.close () method closes the output stream and the data forced transmission is displayed.</p> <p>Writing content in a new window</p> <p>Take a look at the script programs below:</p> <p>Var Win = WINDOW.Open ("", "WIN", "width = 300, Height = 200"); // a window Object</p> <p>Win.Document.open ("text / html", "replace");</p> <p>Win.Document.write ("<html> <head> <title> new document </ title> </ head></p> <p><Body> hello, world! </ Body> </ html> ");</p> <p>Win.Document.close ();</p> <p>The first statement opens a new window that uses an empty document parameter (""), and the return value is assigned to the variable Win. Then, we use the new window's document object Win.Document, written some HTML. Defining "Replace" is very necessary because we don't want a blank page to occupy one in history.</p> <p>Because we deal with the same document object, maybe it is also assigned to another variable:</p> <p>Var Win = WINDOW.Open ("", "WIN", "width = 300, Height = 200"); // a window Object</p> <p>VAR DOC = Win.Document;</p> <p>Doc.open ("Text / HTML", "Replace");</p> <p>Doc.write ("<html> <head> <title> new document </ title> </ head> <body> Hello,</p> <p>World! </ body> </ html> ");</p> <p>Doc.close ();</p> <p>We can also use the WITH statement:</p> <p>Var Win = WINDOW.Open ("", "WIN", "width = 300, Height = 200"); // a window Object</p> <p>WITH (Win.Document) {</p> <p>Open ("Text / Html", "Replace");</p> <p>Write ("<html> <head> <title> new document </ title> </ head> <body> Hello,</p> <p>World! </ body> </ html> ");</p> <p>CLOSE ();</p> <p>}</p> <p>JavaScript Window Function Guide Reference The window has been opened</p> <p>January 21, 2001 11:10:51 Caid.com listening to the wind compile</p> <p>If you want to associate a specified window, you can use the "Target property of the <a> tag. A browser window does not have a name unless you assign you. When you use the target property to open a new window via a link, you assign a clear name: <a href="http://www.intel.com/" target="review"> Intel </ A></p> <p>The front link opens a new window and called Review. The following link produces the same effect by JavaScript:</p> <p><A href = "http://www.intel.com/"</p> <p>OnClick = "WINDOW.Open ('http://www.intel.com/', 'review'); Return False> Intel </A></p> <p>As you can see, assign a name to a new window is a very simple thing. However, give a window name, or name it to a window generated, what will it?</p> <p>The Name property of the Window object allows you to set the name of any window via JavaScript. If you want to create a new window, it can associate the link and form of the father window, you must assign a name to the opener:</p> <p>WINDOW.NAME = "main";</p> <p>Var map = WINDOW.OPEN ("NewPage.html", "MAP");</p> <p>If the following link is included in NewPage.html, the following page is loaded in the parent window:</p> <p><a href="http://www.docjs.com/" target="main"> DOC JavaScript </A></p> <p>Open person's properties</p> <p>Opener property settings or retrieves references to the window that creates the current window. When the OPEN () method opens a source document on the target window, the Opener property (Window object belonging to the target window) defines the window where the source document is located. This property has been existed in the window opened, so it is still accessible even if the URL in the new window changes.</p> <p>The Opener property is a reference to the parent window Window object, so you can make full use of this property, through the script, execute any action on the open window in a new window. For example, use the following script in the target document to modify the background color of the open window:</p> <p>WINDOW.OPENER.Document.bgcolor = "geige";</p> <p>Oh, if you are too gentle, you may notice the error of this statement above. We must check if the window still exists before you can decide to modify its related properties. Below is the correct code:</p> <p>IF (window.opener &&! window.opener.closed)</p> <p>WINDOW.OPENER.Document.bgcolor = "geige";</p> <p>The Opener property is very useful because it establishes the two-way link between the open window and the opened window.</p> <p>Let us give a practical example to see if it works, the following is the HTML code that appears on the home page:</p> <p><Form name = "stockform"> Enter your favorite tech stock:</p> <p><Input type = "text" name = "stockbox" size = "10" value = "> <input type =" button "value =" list "onclick =" showlist () "></p> <p></ Form></p> <p>Note that the name of the form is the stockform, the name of the text domain is the stockbox, the "List" button activates the showlist () function. At the same time, in the document</p> <p>The ONUNLOAD event handler is set in the <body> tag, which will execute the REMLINK () function. Below is the code of these 2 functions:</p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function showlist () {</p> <p>SLIST = WINDOW.OPEN ("stocklist.html", "list", "width = 150, height = 210");</p> <p>}</p> <p>Function translink () {</p> <p>IF (window.slist && window.slist.open &&! window.slist.closed)</p> <p>WINDOW.SLIST.OPENER = NULL;</p> <p>}</p> <p>// -></p> <p></ Script></p> <p>When the current document is uninstalled, the RENER attribute of the REMLINK () function set the sub-window is NULL. The script in the new window checks the Opener property before allocating text domain values. We must use this function because if a different document is loaded in a new window, this window's script cannot access the text box.</p> <p>Here is the code of stocklist.html:</p> <p><Html></p> <p><HEAD></p> <p><Title> stock list </ title></p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function Pick (Symbol) {</p> <p>IF (window.opener &&! window.opener.closed)</p> <p>Window.opener.document.stockform.StockBox.Value = Symbol;</p> <p>WINDOW.CLOSE ();</p> <p>}</p> <p>// -></p> <p></ Script></p> <p></ HEAD></p> <p><Body></p> <p><Table border = "1" cellspacing = "0" cellpadding = "5"></p> <p><TR BGCOLOR = "# cccccc"> <td> <b> NYSE </ b> </ td> <td> <b> NASDAQ </ b> </ td> </ tr></p> <p><Tr> <td> <a href="javascript:pick('aol')"> aol </a> </ td></p> <p><TD> <a href="javascript:pick('tco' )"> csco </a> </ td> </ tr> <tr> <td> <a href = "JavaScript: PICK ('CPQ') "> Cpq </a> </ td></p> <p><TD> <a href="javascript:pick(.intc' )"> intc </a> </ td> </ TR></p> <p><TR> <TD> <a href="javascript:pick('nok' )"> Nok </a> </ td></p> <p><TD> <a href="javascript:pick('tunw' )"> Sunw </a> </ td> </ tr></p> <p><Tr> <td> <a href="javascript:pick('lu' )"> lu </a> </ td></p> <p><TD> <a href="javascript:pick('amzn' )"> amzn </a> </ td> </ tr></p> <p><TR> <TD> <a href="javascript:pick('t'> ""> t </a> </ td></p> <p><TD> <a href="javascript:pick(Oft' )"> MSFT </A> </ TD> </ TR></p> <p></ Table></p> <p></ Body></p> <p></ Html></p> <p>JavaScript Window Function Guide Create Dialog</p> <p>January 21, 2001 11:10:47 Said.com listening to wind compilation</p> <p>JavaScript supports several built-in dialogs: Window.Art (), Window.confirm (), and Window.Prompt (). When a dialog is pop-up, the user cannot focus on the initial page unless the dialog operation ends. In other words, the dialog is always focused. Internet Explorer supports some methods, using them to apply them on any new window:</p> <p>ShowModalDialog () (Internet Explorer 4 and above)</p> <p>ShowModelessDialog () (Internet Explorer 5 and above)</p> <p>The following is the syntax of these methods:</p> <p>VreturnValue = WINDOW.SHOWMODALDIALOG (SURL [, varguments] [, SFEATURES]);</p> <p>VreturnValue = WINDOW.SHOWMODELESSDIALOG (SURL [, VARGUMENTS]);</p> <p>The first parameter is a string that specifies the document URL that is loaded and displayed in a new window. The second parameter, Varguments, is a Variant, which specifies the command to display the document. When using this parameter, you can pass any type of array or value. The dialog can pass the value to the caller from the Dialogarguments property of the Window object.</p> <p>When a new window is opened by one of the methods, the new window (dialog box) is closely written with the Dialogarguments property, which contains the value of the Varguments parameter assigned to the call method. Let's take a look at the following statement: Window.ShowModalDialog ("Modalurl.html", Window);</p> <p>Note that the second command parameter is actually the Window object of the current browser window. Below is the code of file modalurl.html:</p> <p><Html></p> <p><HEAD></p> <p><Title> Change the URL </ Title></p> <p><Script language = "javascript"></p> <p><! -</p> <p>Function load (menu) {</p> <p>IF (Window.Dialogarguments && Dialogarguments.Location) {</p> <p>Dialogarguments.location.href = menu.Options [menu.selectedIndex] .value;</p> <p>WINDOW.CLOSE ();</p> <p>}</p> <p>}</p> <p>// -></p> <p></ Script></p> <p></ HEAD></p> <p><Body></p> <p>Pick Your Favorite Investment Site: <p></p> <p><Form> <select name = "menu"></p> <p><Option value = "http://www.fool.com/"> fool.com (The Motley Fool)</p> <p><Option value = "http://www.investor.com/"> Moneycentral Investor</p> <p><Option value = "http://www.theestreet.com/"> theestreet.com</p> <p></ Select></p> <p><Input Type = "Button" Value = "Load" OnClick = "Load (this.form.Menu)> </ form></p> <p></ Body></p> <p></ Html></p> <p>When the user clicks on the "LOAD" button in the dialog, the URL of the opener window becomes the selected value. For the URL of the numerical window document, we must assign a value to the location.href attribute that requires a Window object. Here, we specify that the caller's Window object is the second parameter of the ShowModalDialog () method, so the Dialogarguments attribute in the new window (dialog box) corresponds to the caller's Window object.</p> <p>Attention The object detection block of the function begins. Because the Dialogarguments attribute exists only in a window created by showmodaldialog () and showmodelessDialog (), we must confirm that the attribute is existed before use. Moreover, we need to find a location.href property to confirm that the Dialogarguments property really corresponds to a legitimate Window object.</p> <p>The last statement of the LOAD () function closes the dialog, and the specified document can be loaded in the original window. Note that if we use the showmodelessdialog () method to replace the showModalDialog () method, we do not need to close the window, because even if the dialog is still open, the new URL will still be loaded below the window (opener). Here, when the caller's URL changes (call the new page), the dialog is turned off. When ShowModelessDialog () is executed in Internet Explorer 5, a dialog appears in front of the browser window. The user can still manipulate the following window, but the dialog will always be on. The dialog is associated with the open browser window, so if the user generates a different window, the dialog is hidden behind it with its generator. Note that a Modeless dialog is actually connected to a document containing a script that generates its, if the user loads another different URL in the opener window, the dialog box will automatically shut down. The ShowModalDialog () method in Internet Explorer 4 is completely different. It creates a Modal dialog and keeps focus until it is closed. The user cannot access the opener window at all. A Modal dialog is associated with the open browser window, so if the user produces a different browser window, the dialog is hidden below the active window with its original window.</p> <p>It is time to come back to discuss the parameters of ShowModalDialog () and ShowModelessDialog () methods. The third parameter, SFEATURES is a string that specifies the modified feature of the dialog window, which is the use of one or more of the following quantities:</p> <p>Dialogheight: Iheight</p> <p>Set the height of the dialog window. Although the user can manually adjust the height of a dialog as a smaller value (required to generate the dialog that is sized), you can specify the minimum DialogHT is 100 pixels. Note that in Internet Explorer 4.0's default measurement unit "EM" in Internet Explorer 5, it is PX (pixel) in Internet Explorer 5. To maintain consistency, specify DialogHeight and DialogWidth in pixels when designing the Modal dialog.</p> <p>Dialogwidth: iWidth</p> <p>Set the width of the dialog window.</p> <p>Dialogleft: IXPOS</p> <p>Set the dialog window relative to the LEFT position in the upper left corner of the desktop.</p> <p>Dialogtop: iYpos</p> <p>Set the dialog window relative to the top position in the upper left corner of the desktop.</p> <p>Center: {YES | NO | 1 | 0}</p> <p>Specifies whether to place the dialog on the desktop, the default value is "yes". To avoid hooking, you can set it to Dialogleft or Dialogtop.</p> <p>Help: {yes | no | 1 | 0}</p> <p>Specifies whether or not the context-sensitive help icon is displayed in the dialog window. The default is "yes".</p> <p>Resizable: {YES | NO | 1 | 0} (Internet Explorer 5 and Above)</p> <p>Specifies whether the dialog window is changeable. The default is "no".</p> <p>Status: {yes | no | 1 | 0} (Internet Explorer 5 and above) Specify whether dialog window displays status bar. For non-dependent dialog windows, the default value is "YES"; for the dependent dialog window, the default value is "no".</p> <p>Object detection</p> <p>ShowModalDialog () and ShowModelessDialog () methods are not supported by all browsers that support JavaScript. Before calling any method, we must confirm their validity:</p> <p>IF (Window.ShowModalDialog) {</p> <p>...</p> <p>}</p> <p>IF (window.showmodelessdialog) {</p> <p>...</p> <p>}</p> <p>If the user's browser does not support the required method, you may want to consider a tolerance, which can be implemented by calling the window.open () method:</p> <p>IF (Window.ShowModalDialog) {</p> <p>Win = WINDOW.SHOWMODALDIALOG ("MyDialog.html", ...);</p> <p>} else {</p> <p>Win = WINDOW.OPEN ("MyDialog.html", ...);</p> <p>}</p> <p>A Cross Browser Modal dialog</p> <p>Take a look at the definition below (Navigator):</p> <p><Body onblur = "Window.focus ()"></p> <p>If you use the above event handler in the <body> tag, the window containing the document will be focused until the user turns it off. Some differences between this only Navigator applicable technology and Internet Explorer's showModalDialog () method. The focused window is not associated with the specified window or document. That is to say, the user cannot adjust to other browser windows, even if it is not the window of the dialog.</p> <p>JavaScript Window Function Guide Create a pop-up window</p> <p>January 21, 2001 11:10:45 Said.com listening to wind compilation</p> <p>Internet Explorer 5.5 Supports a new WINDOW object: CREATPOPUP (). You can create a pop-up window as you:</p> <p>Var popupobj = window.createpopup ();</p> <p>When you create this object, the pop-up window is not displayed. You have to call its SHOW method:</p> <p>Popupobj.Show (Yoffset, Xoffset, Width, Height, ReferenceObj)</p> <p>it's here:</p> <p>YOFSET is the horizontal offset of the pop-up distance from the upper left corner of the screen.</p> <p>Xoffset is a vertical offset from the upper left corner of the pop-up window.</p> <p>Width is the width of the pop-up window.</p> <p>Height is the height of the pop-up window.</p> <p>ReferenceObj is an optional parameter that replaces references for referring to Yoffset and Xoffset on the upper left corner of the screen.</p> <p>Let us demonstrate the use of new pop-up windows. If you click on the link below, a menu of all this tutorial will pop up. Note that when the menu pops, the page scroll back to its top. How do we implement this pop-up window? First, you need to define a visible menu, which will then be reproduced into the menu. To achieve hidden links, you can place the menu to a hidden location. We select the location (-1000, -1000) and define it in the style tag of the menu (a place in the head section):</p> <p><Style></p> <p>. Menu {Position: absolute; top: -1000; left: -1000} </ stop></p> <p>We do the menu as a list of tables:</p> <p><Table class = menuid = SubMenu></p> <p><TR> <TD NOWRAP></p> <p><a href="names.html" target="content"> How to name your windows and frames </A></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="open.html"> How to open a new window </a></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="features.html"> How to specify the features of a new window </a></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="utilize.html"> How to utilize the window features </A></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="exist.html"> How to check if a window exists </A></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="reference.html"> How to close a window </A></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="manipulate.html"> How to manipulate a window </A></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="write.html"> How to write content to a window </a></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="opener.html"> How to reference the Opener </A></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="dialog.html"> How to create a dialog box </a></p> <p></ Td> </ tr></p> <p><TR> <TD NOWRAP></p> <p><a href="popup.html"> How to create a pop-up window </A></p> <p></ Td> </ tr></p> <p><TR> <TD> </ TD> </ TR></p> <p></ Table></p> <p>The link itself (tutorial page) does not change the URL, but when it is clicked, call the showMenu () function: <a href='#' onclick='showmenu(thiS, Submenu)'> Tutorial's Pages </A></p> <p>The showMenu () function has 2 parameters, one is a link object, which calls the function, the other is the ID of the menu. The first behavior we have to take is the Body object that allocates the pop-out window:</p> <p>Var popupbodyobj = popupobj.document.body;</p> <p>Then, set the boundary to 1 pixels, purple, solid styles:</p> <p>Popupbodyobj.style.Border = "1px purple solid";</p> <p>The content of the population pop-out window is never a trivial work, and one of the implementations is to use InnerHTML and OuterHTML:</p> <p>Popupbodyobj.innerhtml = menuid.outerHTML;</p> <p>Next, we need all links to assign the onclick event handler to define the response function for this event to Doculick.</p> <p>For (VAR i = 0; i <popupbodyobj.all.length; i ) {</p> <p>IF (PopuPbodyobj.all [i] .tagname == "a")</p> <p>Popupbodyobj.all [i] .onclick = doclick;</p> <p>}</p> <p>Below is all of the code of the showmenu () function:</p> <p>Function Showmenu (Linkobj, Menuid) {</p> <p>Var popupobj = window.createpopup ();</p> <p>Var popupbodyobj = popupobj.document.body;</p> <p>Popupbodyobj.style.Border = "1px purple solid";</p> <p>Popupbodyobj.innerhtml = menuid.outerHTML;</p> <p>For (VAR i = 0; i <popupbodyobj.all.length; i ) {</p> <p>IF (PopuPbodyobj.all [i] .tagname == "a")</p> <p>Popupbodyobj.all [i] .onclick = doclick;</p> <p>}</p> <p>Popupobj.Show (0, Linkobj.offsetHeight, Menuid.offSetWidth, Menuid.offsetHeight, Linkobj);</p> <p>}</p> <p>The last statement of the function is to display the pop-up window. We placed the pop-up window next to the link to LinkObj. If you omit this reference, the pop-up window will be placed in the upper left corner of the screen. Level offset is 0. To avoid the window pop-up, the link is hidden, we want to set the vertical offset for the link height, linkobj.offsetheight. Naturally, we set the width and height of the window to the menu of the initial menu (Menuid.OffsetHeight).</p> <p>Function doclick () is a 2-line code program that modifies the URL (Parent.href) of the current window to click on the URL (this):</p> <p>Function doClick () {</p> <p>Parent.location = this.href; Return False;</p> <p>}</p> <p>to sum up</p> <p>In this tutorial, we tried to cover most of the content of JavaScript for the window-related features. We show you how to open a new window according to your requirements, how to write content in the window, manipulate it, close it. At the same time, we introduced how to reference the parent window that opens the window. Finally, we have come into contact with 2 special types of windows: dialogs and pop-up windows.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-55614.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="55614" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.030</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'CKcU5vcxU4RaCSMS8SqQj6UxQWTz2n5KwwiHEss2_2BphgYbSGtQtG2AhiqcNPG3CmzN6rGr_2FD2g8HDU5aRRT2_2Fw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>