=============
Reference methods within the same page:
1. Use ID:
Link1.href
2. Use name:
Document.all.link1.href
3, the use of Sourseindex:
document.all (4). href/note, the front also has HTML, head, title and body, so it is 4
4, use the link collection:
Document.anchors (0). href//All collections have all, anchors, applets, areas, attributes, Behaviorurns, bookmarks, boundelements, Cells, childnodes, children, controlrange, elements, embeds, filters, forms, frames, images, imports, links, Mimetypes, Options, plugins, rows, rules, scripts, stylesheets, tbodies, Textrectangle, please refer to the MSDN introduction. In fact, Method 3 and Method 4 are the same set of uses, just one is all, which can include all the tags on the page, and anchors only includes links.
5, getElementById:
document.getElementById ("Link1"). href
6, Getelementsbyname:
Document.getelementsbyname ("Link1") [0].href//This is also a collection, a collection of all tags with the name equal to the parameters of the method
7, getElementsByTagName:
document.getElementsByTagName ("a") [0].href//This is also a collection that is a collection of all tags with a tag name equal to the parameters of the method
8, Tags set:
Document.all.tags ("A") [0].href//As Method 7 gets a collection by tag name
In addition, Event.screlement can obtain a reference to the markup of the triggering time; Document.elementfrompoint (x,y) can obtain a reference to the elements at the x and Y coordinates ; Document.body.componentFromPoint (Event.clientx,event.clienty) can obtain a reference to the element at which the mouse is located, and can also be referenced through the parent-child node of the element and the sibling node relationship. such as nextsibling (the latter node of the current node), previoussibling (the previous node of the current node), childnodes, children, FirstChild, LastChild, Parentelement are some references to parent-child nodes and sibling nodes, and are not limited to this.
This is a common reference method on the same page, and it is also involved in different pages of
=============
For frames-framed pages, you can use Parent.frames ("frame name"), Top.frames ("frame name") to refer to different frames, with the following references the same as the same page, multiple parent is supported.
For example:
Parent.frames ("Frame1"). Document.all.link1
Top.frames ("Frame1"). Document.all.link1
=============
For window.open () Windows, you can use Var newwin=window.open (), and then use Newwin to refer to the new window, followed by the same reference as the same page. A new window can use Window.opener to refer to the window that opens it, and you can write a opener, for example:
var newwin=window.open ()
Parent window (here is a window using the window.open () method):
NEWWIN.DOCUMENT.ALL.LINK1//Parent window This sentence can refer to an object in a new window
child window (window.open () method open window):
OPENER.DOCUMENT.ALL.LINK1//child window This clause refers to the object of the parent window
Multiple opener are also supported, for example: OPENER.OPENER.DOCUMENT.ALL.LINK1
The method is varied, sometimes needs to be based on specific circumstances, flexible use can be easily.
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.