<img id='Img1' src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png' onclick='alertImgSize(this)' style='cursor:pointer;' />
<script>
function alertImgSize(ElemId) {
var Size = GetImageSize(Img1);
alert('Width : ' + Size.Width + 'px\nHeight : ' + Size.Height + 'px');
}
function GetImageSize(ElemId) {
with(TmpImg = document.body.appendChild(document.createElement('img'))) {
src = ElemId.src;
var Width = offsetWidth;
var Height = offsetHeight;
}
document.body.removeChild(TmpImg);
return {
Width : Width, Height : Height
}
;
}
</script>
아래 구글 이미지를 클릭해보세요.
댓글 없음:
댓글 쓰기