Could someone show me how to get th largest embed
or object
in an web page which has the l开发者_开发问答argest dimensions. I need to be able to do this without any JS libraries.
Thanks.
Supposing you have every <embed>
element in an <object>
(working example):
function largestFlash() {
var all = document.getElementsByTagName("object");
var largest, largest_dimension = 0;
for (var i = all.length; i--;) {
var width = parseInt(all[i].width, 10);
var height = parseInt(all[i].height, 10);
var dimension = width * height;
if (dimension > largest_dimension) {
largest = all[i];
largest_dimension = dimension;
}
}
return largest;
}
精彩评论