Window object:
DOM: Document Object Model--tree model
Documents: Tag documents, objects: documents in each Element object, model: abstract Things
A: window:
Property (value or Sub-object):
Opener: Opens the source window of the current window, if the current window is open for the first time, then opener is NULL, you can use this property to close the source window.
Method (function):
Event (pre-Set program, triggered):
1.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.
5:close (): Close the specified window
Window.close (): Close the current window
W.close (): Close W window
Close multiple child windows: The window placed in the array: W[i].close ();
Close the source window that opens the current window
Window.opener.close ();
6: Interval and delay: *******
Window.setinterval ("Code to execute", number of milliseconds in interval)
Window.clearinterval (ID of the interval); The code that is used to clear every few seconds after the loop is executed
Window.settimeout ("Code to execute", number of milliseconds to delay)
Window.cleartimeout (deferred ID); Clear settimeout, generally deferred execution is more commonly used.
7: Page Action
Window.navigate ("url"); jump page;
Window.moveto (x, y); Move page
Window.resizeto (wide, high); Adjustment page
Window.scrollto (x, y); scroll page to where
8: Modal dialog box
window.showModalDialog ("url", "Value passed to target dialog box", "window feature parameter") Open modal dialog box
Modal dialogs must be turned off to operate on the back end. The difference between a module dialog box and a window is always pinned.
Feature parameters: separated by semicolons, pixel size with px. Dialogheight,dialogwidth,center, et
Window.showmodelessdialog ("url", "Value passed to target dialog box," "Window feature Parameter") opens the Non-module dialog box without closing to the back of the operation.
9. Window.history Objects
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. *
Ten. Window.location objects
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
One. Window.status objects
Status bar, you can add the text you want to display to the status bar
Window.status= "What to display in the status bar"; Set the status bar text
Document object:
<style type= "Text/css" >
*{margin:0px Auto; padding:0px; font-family: Microsoft Jacob Black; font-size:14px;}
#d {width:200px; Height:200px;background-color: #669}
</style>
<body>
<div id= "a" ><span>hello</span></div>
<div id= "D" > Test div</div>
<span id= "B" ></span>
<div class= "AA" ></div>
<div class= "AA" ></div>
<span class= "AA" ></span>
<input type= "text" name= "CC"/>
<input type= "text" id= "txt" value= "Hello"/>
<input type= "Radio" name= "Sex" id= "Sex" checked= "checked" test= "AA"/> Male
<input type= "button" value= "Find Element" onclick= "Show ()"/>
<script type= "Text/javascript" >
function Show ()
{
Search by ID
Alert (document.getElementById ("B"));
Search by class
var attr = document.getelementsbyclassname ("AA");
Alert (attr[2]);
Search by name
Alert (Document.getelementsbyname ("cc") [0]);
Search by Tag name
Alert (document.getElementsByTagName ("div"). length);
Action Content
Common Elements
var a = document.getElementById ("a");
1. Get content Text: alert (a.innertext);
2. Set content: A.innertext = "OK";
3. Get the Content code: alert (a.innerhtml);
4. Set content: a.innerhtml = "<span style= ' color:red ' >ok</span>";
5. Display Label://a.innertext = "<a href= ' # ' > Hyperlink </a>";
Form elements
var a = document.getElementById ("txt");
alert (A.value);
A.value = "OK";
Action Properties
var a = document.getElementById ("Sex");
1. Adding attributes
A.setattribute ("Checked", "checked");
2. Removing attributes
A.removeattribute ("checked");
3. Get Properties
Alert (A.getattribute ("Test"));
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";
}
</script>
Window object, document object;