JS. findElementById () Introduction _ javascript skills

Source: Internet
Author: User
Tags old windows
JS. findElementById () is a good example. If you are interested, refer The Code is as follows:


His. findElementById = function (identifier, frame ){
If (! Frame ){
Frame = window;
}

Var element = frame.doc ument. getElementById (identifier );
If (element & element. getAttribute ('id') === identifier ){
Return element;
}
// Else if (browserVersion. isIE | browserVersion. isOpera ){
/// SEL-484
// Var xpath = '/descendant: * [@ id =' + identifier. quoteForXPath () + ']';
// Return this
//. FindElementByXPath (xpath );
//}
Else {
// MOD 2011-12-9 some new windows have the same frame as old windows. Generally, a new window is operated first. Forward from the back
If (frame. frames & frame. frames. length> 0 ){
For (var I = frame. frames. length-1; I> = 0; I --){
Element = this. findElementById (identifier, frame. frames [I]); // frames[ I }.doc ument. getElementById (identifier );
If (element & element. getAttribute ("id") === identifier ){
Return element;
}
}
}
}
Return null;
};

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.