This is the 23rd day of my participation in the More text Challenge. For more details, see more text Challenge
The window object
-
MoveBy (x, y) function: from the level of the current position x mobile form, a pixel vertical movement form y, a pixel x is negative, move to the left forms, y is negative, will move up the form
-
MoveTo (x,y) function: moves the upper left corner of the form to the point (x,y) relative to the upper left corner of the screen, and moves the form out of view when negative values are used
-
ResizeBy (w, h) function: Adjust the width by W pixels and the height by H pixels relative to the form’s current size. If the parameter is negative, the form is shrunk, otherwise it is enlarged
-
ResizeTo (w, h) functions: the window width is adjusted for w, a pixel height is adjusted for h pixels
-
The scrollTo(x, y) function: If there is a scroll bar in the form, move the horizontal scroll bar to x pixels relative to the width of the form and the vertical scroll bar to y pixels relative to the height of the form
-
The scrollBy(x, y) function: If there is a scroll bar, move the horizontal scroll bar to x pixels relative to the current horizontal scroll bar (x pixels to the left), and move the vertical scroll bar to y pixels relative to the current vertical scroll bar height (y pixels down).
-
The focus() function: causes a form or control to get focus
-
Blur () function: As opposed to focus, it causes a form or control to lose focus
-
Open (URL, name, features, replace) function: opens (pops up) a new form
Url – The URL to load the form
Name – the name of the new form (or the value of the HTML target attribute, target)
Features — a string representing the features of the form, with each feature in the string separated by a comma
Replace — A Boolean value that indicates whether the newly loaded page replaces the currently loaded page. This parameter is not usually specified
- The close() function: closes the form
The opener attribute: a reference to the new form
- Alert (STR) function: Pops up the message dialog (with an OK button)
- Confirm (STR) function: Pops up a message dialog box with an OK button and Cancel button.
- Prompt (STR1, STR2) function: Displays a message dialog (with an OK button, Cancel button, and a text input box)
The defaultStatus property: Changes the default display of the browser’s status bar (when no other status bar is displayed). The area at the bottom of the browser is called the status bar and is used to display information to the user
Status attribute: Temporarily changes the display of the browser’s status bar. The area at the bottom of the browser is called the status bar and is used to display information to the user
- The setTimeout(codes, interval) function: pauses for a specified number of milliseconds before executing the specified code
- ClearTimeout (id) function: cancellations the code that the specified setTimeout function will execute
- The setInterval(codes, interval) function: executes the specified code at a specified number of milliseconds
- ClearInterval (id) : cancellations the code that the specified setInterval function will execute
The history object:
- The go () function
- The back () function
- Forward () function
Location object
- Hash property: returns whatever follows the URL#, or null if there is no #
- The host property: returns the domain name portion of the URL, such as www.baidu.com
- Hostname property: Returns the primary domain name portion of the URL, such as dreamdu.com
- Href property: returns or sets the URL of the current document
- Pathname attribute: Returns the portion of the URL after the domain name. For example, www.baidu.com/xhtml/ returns/XHTML /
- Port property: Returns the port portion of the URL. For example, www.baidu.com:8080/xhtml/ back to 8080
- Protocol property: Returns the protocol part of the URL. For example www.baidu.com:8080/xhtml/ return (/ /) in front of the content of the HTTP:
- The search attribute: returns the query string portion of the URL. For example, www.baidu.com/baidu.php?i… Return includes (?) What follows? id=5&name=baidu
- Assign (URL) function: sets the URL of the current document
- The replace(URL) function: sets the URL of the current document and removes it from the history object’s address list
- Reload (isServer) function: reload the current page
Parameters that
- IsServer — true reloads the page from the server, otherwise only reloads it from the local browser cache
When no parameter is used, it defaults to False and is reloaded from the local browser cache
The navigator object
- UserAgent property: returns a string representation of the userAgent header (that is, a string containing browser version information, etc.)
- CookieEnabled attribute: Returns whether the browser supports (enables) cookies
The screen object
- AvailHeight property: returns the screen height, in pixels, that the window can use
- AvailWidth property: returns the available screen width of the window, in pixels
- ColorDepth property: Returns the number of color bits represented by the user’s browser, usually 32 bits (bits per pixel)
- PixelDepth property: Returns the number of color bits represented by the user’s browser, usually 32 bits (bits per pixel) (IE does not support this property)
The instance
Example 1
Write code that controls the current browser window, allowing it to move up, down, left, or right, zoom in and out
Example 2
Write code that opens a web address in a new window when a button is clicked, and then closes the new window with code.
Example 3
Write code that will bring up a dialog box when you click the button and prompt the user to enter a value in the dialog box and calculate the sum from 1 to that value
Example 4
Write the code, click the button, and a dialog pops up every 10 seconds, five times, and then ends
Example 5
Write the code, click the button, get the host, hostname, href, pathname, port, protocol information for the current page
Example 6
Write code that opens a web page using the location object’s href method
,
Example 7
Write code to check if the browser’s cookie function is enabled, then modify the cookie function in the browser Settings and verify again
Example 8
Write code to view the maximum height and maximum width of the browser and set the browser window size to the maximum width and maximum height; If the browser window does not start at the top left corner, move it to the top left corner