JS window object

Source: Internet
Author: User

Browse the forum to see, favorite ~~~~

JS window object

  • WindowObjectAttributes and methods:

Format:
[Window.] Properties
[Window.] method (parameter)
Opener. Attribute
Opener. Method (parameter)
Self. Attributes
Self. Method (parameter)
Parent. Attribute
Parent. Method (parameter)
Top. Attributes
Top. Method (parameter)
Window name. Properties
Window name. Method (parameter)

  • Properties of window objects:
Document Current File Information
Location Current URL Information
Name Window name
Status Temporary Information of the status bar
Defaultstatus Status Bar default information
History Web pages recently viewed in this window
Closed Determines whether the window is closed. A boolean value is returned.
Opner Source window of the window opened by the Open Method
Outerheight The vertical size of the window boundary, PX
Outerwidth Horizontal size of window boundary, PX
Pagexoffset Position of page X-Position
Pageyoffset Position of page y-Position
Innerheight The vertical size of the window content area, PX
Innerwidth Horizontal size of the window content area, PX
Screenx X coordinate of the left boundary of the window
Screeny Y coordinate of the upper boundary of the window
Self Current window
Top Top Window
Parent Frame Group of the current window or framework
Frames Corresponding to the frame in the window
Length Number of frameworks
Locationbar Browser address bar
Menubar Browser menu bar
Scrollbars Browser scroll bar
Statusbar Browser Status Bar
Toolbar Browser toolbar
Offscreenbuffering Whether to update the area outside the window
Personalbars Browser's personal toolbar, only Navigator

 

  • Window object method:
Alert (Information string) A warning message is displayed.
Confirm (Information string) Show confirmation dialog box
Prompt (prompt string [, default value]) Display prompt information and provide input fields
Atob (Decoding string) Decodes base-64 encoded strings.
Btoa (string) Base-64 Encoding
Back () Go back to the previous page of history
Forward () Load the next page in the history
Open (URL, window name [, window type])
Focus () Move focus to this window
Blur () Convert window to background
Stop () Stop loading Web pages
Close ()
Enableexternalcapture () Allow window with frame to get events
Disableexternalcapture () Disable enableexternalcapture ()
Captureevents (event type) Capture specific events in the window
Routeevent) Send captured events
Handleevent) Make the processing of specific events take effect
Releaseevents (event type) Release acquired events
MoveBy (horizontal points, vertical points) Relative positioning
MoveTo (x coordinate, Y coordinate) Absolute Positioning
Setresizable (true | false) Whether window size can be adjusted
ResizeBy (horizontal point, vertical point) Relatively adjust the window size
ResizeTo (width, height) Absolutely adjust the window size
Scroll (x coordinate, Y coordinate) Absolute scroll window
Scrollby (horizontal points, vertical points) Relatively scrolling window
Scrollto (x coordinate, Y coordinate) Absolute scroll window
Setinterval (expression, millisecond)
SetTimeout (expression, millisecond)
Clearinterval (timer object)
Cleartimeout (timer object)
Home () Go to the browser settings Homepage
Find ([String [, casesensitivr, backward]) Find a specific string in the window
Print ()
Sethotkeys (true | false) Activate or disable a key combination
Setzoptions () Set the stack sequence when the window overlaps
  • Event handler for window objects:

Onblur ondragdrop onerror onfocus onload onmove onresize onUnload

 

Example 1:
<SCR platinum Pt>

Function checkpassword (testobject ){
If (testobject. value. Length <4 ){
Alert ("password length cannot be less than four ");
Testobject. Focus ();
Testobject. Select ();
}
}
</Scr platinum Pt>
Enter the password:
<Input type = "text">

Example 2:
<SCR platinum Pt>

If (confirm ("are you 18 years old? "))
Location = "adult.htm ";
Else
Alert ("come back when you are an adult! ");

</Scr platinum Pt>

Example 3:
<SCR platinum Pt>

VaR bgcolor =
Prompt ("which background do you like:/n light blue press 1, pink press 2", 1)

If (bgcolor = 1) document. bgcolor = "# ccffff ";
Else if (bgcolor = 2) document. bgcolor = "# ffccff ";
Else document. bgcolor = "# ffffff ";

</Scr platinum Pt>

Example 4:
<SCR platinum Pt>
Function grow (){
ResizeBy (0, 50 );
}

Function shrink (){
ResizeBy (0,-50 );
}

</Scr platinum Pt>
<Body>
Zoom in and out windows
</Body>

Example 5:
<SCR platinum Pt>

Function scrollit (){
For (y = 1; y <= 2000; y ++ ){
Scrollto (1, y );
}
}

</Scr platinum Pt>
<Body parameters ndblclick = scroltasks ()>
Double-click the mouse to automatically scroll the screen...
<Br> <BR>
<Br> <BR>
<Br> <BR>
<Br> <BR>
... The end...
</Body>

  • Window specification parameters of the Open Method: (Yes/No, 1/0)

Format: [Var new window object name =] window. Open ("url", "windowname", "windowfeature ")

Alwayslowered Whether to push the stack displayed in the window to a layer
Alwaysraised Whether to push the stack displayed in the window to a layer
Dependent Whether to dependency the window with the current window
Fullscreen Full Screen Display
Directories Display connection Toolbar
Location Show URL Toolbar
Menubar Show menu Toolbar
Scrollbars Display scroll bar?
Status Display status bar?
Titlebar Display title bar?
Toolbar Whether to display Standard toolbar
Resizable Can I change the window size?
Screenx Left boundary distance of window
Screeny Window upper boundary distance
Top Window upper boundary
Width Window width
Height Window height
Left Left Border of window
Outerheight The height of the boundary outside the window.
Personalbar Show personal toolbar?

 

Note: open ("", "", "menubar ")
Open ("", "", "menubar = 1 ")
Open ("", "", "menubar = yes ")

Example 1:
<SCR platinum Pt>

Document. Write ("Wenge Network TechnologyLearningNetwork ");
Open ('1.htm', '', 'height = 100, width = 300 ');

</Scr platinum Pt>

<! -------- 1.htm -------->
<Title> welcome </title>
<Body>


<Center>
<Font color = "blue" size = "5"> welcome </font> <br>
This is a small place for technical study <br>
</Center>

</Body>

Example 2:
<SCR platinum Pt>

Document. Write ("Wenge Network Technology Learning Network ")
Hellowin = open ('1.htm', '', 'height = 100, width = 300 ');
VaR line1 = "<font color = 'blue' size = '5'> welcome </font> <br>"
VaR line2 = "this is a technology study world"
Hellowin.doc ument. Write (line1 + line2)
Hellowin.doc ument. Title = "welcome"

</Scr platinum Pt>
Example 3:
<SCR platinum Pt>

Window. defaultstatus = "the best online learning website ";

</Scr platinum Pt>
<A href = "http://www.hubert.idv.tw">
Wenge Network Technology Learning Network </a>

Example 4:
<SCR platinum Pt>

Querywin = open('1.htm', '', 'height = 100 ,')

</Scr platinum Pt>
Use the Child Window to change the background color of the parent window

/* -------- 1.htm --------*/
<SCR platinum Pt>
Function passtoopener (color ){
Opener.doc ument. bgcolor = color;
Self. Close ();
}
</Scr platinum Pt>
<Center>
Select the color you like? <Br>
<Font> light blue </font>
<Font> light red </font>
</Center>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.