JS get content Layer content raw size scroll bar height page actual size

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax code content document function functions get html

Here provide three kinds of JS functions, pagination is to get the content layer content raw size to get the height of the scroll bar to get the actual size of the page JS code OH.

<!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=" HTML; charset=gb2312 "/>


<title>js Get content layer content raw size scroll bar height page actual size </title>


<script language= "Web Effects" >


get content Layer content raw size


function Getconsize (conid) {


var Conobj=document.getelementbyid (Conid)


conobj.style.position = "differs";


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


conobj.style.display= "";


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


conobj.style.display= "None";


return arrayconsize;


}


function InsertAfter (newelement,targetelement) {//Insert


var parent = Targetelement.parentnode;


if (parent.lastchild = = targetelement) {


Parent.appendchild (newelement);


}


else{


Parent.insertbefore (newelement,targetelement.nextsibling);


}


}


//Get the height of the scroll bar


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;


}


//Get the actual size of the page


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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.