Window.open () made a more detailed explanation

xiaoxiao2021-03-06  18

In fact, this example is not difficult, only a more special usage of Window.Open (), the process is this: first open a window, then write a piece of code (ie, the parameter code) to this window. The OPEN () method is explained below.

First look at the usage: newwin = window.open ('url', 'name', 'features');

NEWIN is a variable of a Window object, representing a new window, we can use newwin to call this window for a certain operation, such as newwin.close () (close the window); URL is the URL of the file opened; Name is The name of the window; Features is a string that represents the properties of the new window, there are multiple options, separated by commas, such as: window.Open ('url', 'name', 'width = 400, height = 300') . The following is listed below attributes in the new window in IE4 (including IE4) (ie, fetures in the above parameters):

Attribute value / unit expressed meaning

Toolbar Yes / No. / 1/0 toolbar

Location Yes / No / 1/0 Address Bar

Font-size font size, syntax with CSS, such as Font-size: 12px

Font-Weight defines a variety of fonts

Font-Style uses a variety of font properties

EdgeStyle Raised / Sunken Window Border Style

Bordersize Thick / Thin Window Size Border Size

Helpicon Yes / No / 1/0 Whether to display help icon in the title bar

Minimize Yes / No / 1/0 Whether to display a small icon in the title bar

Maxnimize Yes / No / 1/0 Whether to display a large icon in the title bar

SystemMENU YES / NO / 1/0 System menu is valid in the border icon

Directories YES / NO / 1/0 Directory Icon

STATUS YES / NO / 1/0 window bottom status line

MenuBar YES / NO / 1/0 menu

Scrollbars Yes / NO / 1/0 allows horizontal and vertical scrolling

Resizealbe Yes / No / 1/0 Can change the window size

Width PX window width

HEIGHT PX window height

Top PX relative to the top position of the desktop

LEFT PX is relative to the left side of the window

Center Yes / NO / 1/0 relative to the center position of the desktop

The above, a more detailed explanation for Window.Open (), which is a more special usage, which is used in this example. Let's take a look at the only two lines of code of the runcode () function:

Var newwin = window.open ('', '', '');

Newwin.document.writeln (code);

The first sentence has been described above, that is, open a window. But there is no parameters here. If there is no next sentence, it will open a new window with his parent window, then let's take a look at what is the meaning of the next sentence? Newwin is a variable of the new window, which means that it must be a new open window. Document.writeln () is an output statement, code is a parameter, that is, the code to run. Then, newwin.document.writeln (code) means writing to the newly opened window, in other words, the Code code also shows its effect in the new window, thus implementing "running" The function of the code. This section, this is the end, is it very simple?

转载请注明原文地址:https://www.9cbs.com/read-56433.html

New Post(0)