Some actions of the Windows Object Document Object 9.23

Source: Internet
Author: User

function: four elements

1. Return type
2. Name of function
3. Parameter list
4. Function body

window. Object


Opener Open the source window of the current Window alert (window.opener);


Open () Example:

Set a button name for him first.

window.open ("Part I", "Part II", "Part Three", "Part IV");

Feature parameters:

Part I: Write the address of the page you want to open
Part Two: Open the way that _blank is open in a new window _self
Part III: Control open windows, can write multiple, separated by a space
Toolbar=no New Open Window no toolbar
Menubar=no no menu bar Status=no no status bar
width=100 height=100 Width Height
left=100 Open Window How far to the left
Resizable=no window size is not adjustable
Scrollbars=yes scroll bar appears
Location=yes has address bar

Return value: Newly opened Window object

2: The simplest open window
window.open ("http://www.baidu.com", "_blank", "toolbar=no"); Open Baidu in a new window.

3: Open the window and save it in a variable
var w= window.open ();

4: Open the window only once, examples are as follows:

if (w==null)
{
W=window.open ("http://www.baidu.com", "_blank", "toolbar=no");
}

Here with an If statement, determine whether the value of W is empty, open a window after the value of W is not empty, and then click on the mouse to call this function does not execute open a new window.


Close () Closes the specified window
Setinteval () ("code to execute", number of milliseconds in interval )
SetTimeout () ("code to execute", number of milliseconds to delay )
  

History

Window.history Object

History allows you to move the page forward or backward through history

Window.history.back (); back

Window.history.forward (); advance

Window.history.go (n); n is a positive number representing the forward n pages, and n is a negative number representing the backward n pages.


Location


Location Bar

var s = window.location.href; Gets the address of the current page

Window.location.href= "http://www.baidu.com"; Change page address, will jump page *******

Window.location.hostname: Host name, domain name, site name, available variable receive

Window.location.pathname: path name, available variable receive


Document. Object

Find elements: The First method: getElementById () Search by ID


Alert (document.getElementById ("ID name")); Search by ID
Search by class. Returns an array with several tag names coming out of the number.

The second method: Getelementsbyclassname () Search by class, return array


var attr = document.getelementsbyclassname ("class name");
Alert (attr[2]);

Third method: Getelementsbyname () Search by name, return array


Search by name. Returns an array with several tag names coming out of the number.
Alert (Document.getelementsbyname ("name name") [0]);

Fourth method: getElementsByTagName () Search by tag name, return array



Search by tag name. Returns an array with several tag names coming out of the number.
Alert (document.getElementsByTagName ("div"). length);


What to do:
Common elements:


innertext Get the content text we can see What to do:

Common elements: examples
var a = document.getElementById ("a");
1. Get content Text
alert (A.innertext);
2. Setting content
A.innertext = "OK"; To set (OK) in (a) just a name can be casually


innerHTML get all the content in the tag all the code including the tag

Example:

3. Get the Content code

alert (a.innerhtml);
4. Setting content
a.innerhtml = "<span style= ' color:red ' >ok</span>";

5. Display the label
A.innertext = "<a href= ' # ' > Hyperlinks </a>";


Form elements:
Value

Action Properties:
. SetAttribute (Property name, property value) setting properties
. RemoveAttribute (property name) removing properties
. GetAttribute (property name) Get property

Action style:


A.style.width Get Style


Cases:::
Action Style
var a = document.getElementById ("D");

1. Get the style, only get the embedded
alert (a.style.width);

2. Set style
A.style.fontsize = "30px";

3. Modify the Style
A.style.backgroundcolor = "green";
a.style.color= "White";

Some actions of the Windows Object Document Object 9.23

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.