PDA

View Full Version : سوال: چطور طول سفحه رو بگیریم؟



p30graph3
شنبه 17 بهمن 1388, 11:44 صبح
سلام

یک سوال دیگه داشتم

آیا تابع یا چیزی هست که بتونیم ازش برای اندازه گیری صفحه ی مورد نظرمون استفاده کنیم؟

مثلا صفحه GOOGLE.COM رو بگیره و بگه ارتفاعش و عرضش چقدره؟

Lagon666
شنبه 17 بهمن 1388, 17:58 عصر
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>docment height/width</title>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">

<script type="text/javascript">
function doClick(){
var x, y, msg='';

// for all except Explorer
if (self.innerHeight) {
x = self.innerWidth;
y = self.innerHeight;
msg += 'self.innerHeight/Width: '
+ y + ', ' + x + 'px';

// Explorer 6 Strict Mode
} else if (document.documentElement
&& document.documentElement.clientHeight) {
x = document.documentElement.clientWidth;
y = document.documentElement.clientHeight;
msg += 'document.documentElement.clientHeight/Width: '
+ y + ', ' + x + 'px';

// other Explorers
} else if (document.body) {
x = document.body.clientWidth;
y = document.body.clientHeight;
msg += 'document.body.clientHeight/Width: '
+ y + ', ' + x + 'px';
}
alert(msg);
}
</script>
</head>
<body onclick="doClick();">
<div style="width: 200px; height: 200px;
border: 1px solid red;">
</div>
</body>
</html>


از اینجا گرفتمش:


http://bytes.com/topic/javascript/answers/151010-how-find-height-width-webpage