Window Object window operations
Window objects are very useful for operating browser windows. developers can move or adjust the size of browser windows. You can perform these operations in four ways:
MoveBy (dx, Dy): Move DX pixels horizontally from the browser window to the current position, and move dy pixels vertically. The DX value is the negative shift left, and Dy is the negative move up.
MoveTo (x, y): Move the browser window so that its upper left corner is located at (x, y) of the user screen. You can use a negative number, but this will remove some windows from the visible area of the screen.
ResizeBy (DW, DH): adjusts the width of the window to DW pixels and the height to Dy pixels relative to the current size of the browser window. When DW and Dy are negative, the window is reduced.
ResizeTo (W, h): Adjust the window width to W, and the height to H. A negative number is not allowed.
Note: Firefox and chrome do not allow this operation by default. You must change it in the security settings.
Effect (in IE browser ):
Navigate to and open a new window
Use window to navigate and open a new window. the open () method, which accepts four parameters, namely, the URL of the page to load the new window, the name of the new window, feature string and description whether to replace the Boolean value of the currently loaded page with the newly loaded page. Generally, only the first three parameters are used. The last parameter is valid only when window. open () cannot open a new window.
The optional values of the third parameter are as follows:
Top = Y coordinate of the pixels window.
| Left = pixels |
The X coordinate of the window. In pixels. |
| Height = pixels |
The height of the window document display area. In pixels. |
| Width = pixels |
The width of the document display area of the window. In pixels. |
| Resizable = Yes | No |
Whether the window size is adjustable. The default value is yes. |
| Scrollable = Yes | No |
Whether to display the scroll bar. The default value is yes. |
| Location = Yes | No |
Whether to display the address field. The default value is yes. |
| Status = Yes | No |
Whether to add a status bar. The default value is yes. |
| Toolbar = Yes | No |
Whether to display the toolbar of the browser. The default value is yes. |
Feature strings are separated by commas. Therefore, there cannot be spaces after commas or equal signs.
Example:
Document Object
You can use the open, write, and close methods of document to write content to the newly opened window, as shown below:
< Script Type = "Text/JavaScript" > Function Run (){ VaR Onewwin = Window. Open ( " About: blank " , " Newwindow " , " Height = 300, width = 400 " ); Onewwin.doc ument. open (); onewwin.doc ument. Write ( " <HTML> <body> <SCRIPT> function test () {alert ('test') ;}</scr " + " EPT> <input type = 'button 'value = 'test' onclick = 'test ()'/> </body> " ); Onewwin.doc ument. Close ();} </ Script > < Input Type = 'Button' Value = 'Run' Onclick = 'Run ()' />
Location object
The location object can be used to parse the URL, for example, the URL is: http://www.cnblogs.com/artwl/archive/2012/04/14/2446762.html#top? Id = 1, then:
Hash: # top
HOST: www.cnblogs.com
Hostname: www.cnblogs.com
Href: http://www.cnblogs.com/artwl/archive/2012/04/14/2446762.html#top? Id = 1
Pathname:/artwl/archive/2012/04/14/2446762 .html
Port: blank
Protocol: http:
Search :? Id = 1