-
Notifications
You must be signed in to change notification settings - Fork 9
/
Notes
33 lines (27 loc) · 838 Bytes
/
Notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Notes:
Determines the size of an image:
<script>
function onImageLoad(aEvent) {
alert("width:" + aEvent.target.width + "\nheight:" + aEvent.target.height);
}
var img = document.createElementNS("http://www.w3.org/1999/xhtml","html:img");
img.addEventListener("load", onImageLoad, false);
img.src = "http://upload.wikimedia.org/wikipedia/commons/0/06/Gigantactis.jpg";
</script>
OR largest image on the page:
<script>
var sHTML = getHTMLSomehow(sURL);
var nMaxDim = 0;
var $pageDOM = $(sHTML);
var $objMaxDimImage;
$pageDOM.("img").each(function(){
var $this = $(this);
var nDim = parseFloat($this.width()) * parseFloat($(this).height());
if (nDim > nMaxDim){
$objMaxDimImage = $this;
nMaxDim = nDim
}
});
alert("Max dim is:" nMaxDim);
alert("Image Source:" $objMaxDimImage.attr("src"));
</script>