js獲取內容層內容原始尺寸 捲軸高度 頁面實際大小

來源:互聯網
上載者:User
關鍵字 網頁製作 Ajax JavaScript

這裡提供三種js函數,分頁是 獲取內容層內容原始尺寸 獲取捲軸的高度 獲取頁面實際大小的js代碼哦。

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "HTTP://www.w3.org/tr/xhtml1/dtd/ xhtml1-transitional.dtd">


<html xmlns="HTTP://www.w3.org/1999/xhtml">


<head>


<meta HTTP-equiv="content-type" content="text/html; charset=gb2312" />


<title>js獲取內容層內容原始尺寸 捲軸高度 頁面實際大小</title>


<script language="網頁特效">


獲取內容層內容原始尺寸


function getconsize(conid){


var conobj=document.getelementbyid(conid)


conobj.style.position = "absolute";


conobj.style.left=-1000+"px";


conobj.style.display="";


var arrayconsize=[conobj.offsetwidth,conobj.offsetheight]


conobj.style.display="none";


return arrayconsize;


}


function insertafter(newelement,targetelement){//插入


var parent = targetelement.parentnode;


if(parent.lastchild == targetelement){


parent.appendchild(newelement);


}


else{


parent.insertbefore(newelement,targetelement.nextsibling);


}


}


//獲取捲軸的高度


function getpagescroll(){


var yscroll;


if (self.pageyoffset) {


yscroll = self.pageyoffset;


} else if (document.documentelement  &&  document.documentelement.scrolltop){


yscroll = document.documentelement.scrolltop;


} else if (document.body) {


yscroll = document.body.scrolltop;


}


arraypagescroll = new array('',yscroll)


return arraypagescroll;


}


//獲取頁面實際大小


function getpagesize(){


var xscroll,yscroll;


if (window.innerheight  &&  window.scrollmaxy){


xscroll = document.body.scrollwidth;


yscroll = window.innerheight + window.scrollmaxy;


} else if (document.body.scrollheight > document.body.offsetheight){


sscroll = document.body.scrollwidth;


yscroll = document.body.scrollheight;


} else {


xscroll = document.body.offsetwidth;


yscroll = document.body.offsetheight;


}


var windowwidth,windowheight;


//var pageheight,pagewidth;


if (self.innerheight) {


windowwidth = self.innerwidth;


windowheight = self.innerheight;


} else if (document.documentelement  &&  document.documentelement.clientheight) {


windowwidth = document.documentelement.clientwidth;


windowheight = document.documentelement.clientheight;


} else if (document.body) {


windowwidth = document.body.clientwidth;


windowheight = document.body.clientheight;


}


var pagewidth,pageheight


if(yscroll < windowheight){


pageheight = windowheight;


} else {


pageheight = yscroll;


}


if(xscroll < windowwidth) {


pagewidth = windowwidth;


} else {


pagewidth = xscroll;


}


arraypagesize = new array(pagewidth,pageheight,windowwidth,windowheight)


return arraypagesize;


}


</script>


</head>

<body>
</body>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.