Home > Web Front-end > JS Tutorial > JS.findElementById() usage introduction_javascript skills

JS.findElementById() usage introduction_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:22:06
Original
2153 people have browsed it
Copy code The code is as follows:

his.findElementById = function (identifier, frame) {
if (!frame) {
frame = window;
}

var element = frame.document.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 the old window. Generally, the new window is operated first. Find from back to front
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].document.getElementById(identifier);
if (element && element.getAttribute("id") = == identifier) ​​{
return element;
}
}
}
}
return null;
};
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template