Jquery plug-in for browsers

Source: Internet
Author: User
Compatible with BackCompat and CSS1Compat pages rendered in two modes. Tested Browser: friefoxie678chromeopera The Code is as follows:


(Function ($ ){
/**
* Get the width of the browser View
*/
$. ViewWidth = function (){
Var w = 0, D = document;
If (D.doc umentElement & D.doc umentElement. clientWidth ){
W = D.doc umentElement. clientWidth;
} Else if (D. body & D. body. clientWidth ){
W = D. body. clientWidth;
}
Return w;
}
/**
* Get the height of the browser View
*/
$. ViewHeight = function (){
Var h = 0, D = document;
If (document. compatMode! = 'Css1compat '){
H = D. body. clientHeight;
} Else {
If (D.doc umentElement & D.doc umentElement. clientHeight ){
H = D.doc umentElement. clientHeight;
} Else if (D. body & D. body. clientHeight ){
H = D. body. clientHeight;
}
}
Return h;
}
/**
* Obtain the height of the canvas (that is, the browser view size when the browser content is insufficient)
*/
$. CanvasHeight = function (){
Var D = document, h = 0;
Hsf-math.max(math.max(d.body.scrollheight,d.doc umentElement. scrollHeight ),
Math.max(D.body.offsetHeight,D.doc umentElement. offsetHeight ),
Math.max(D.body.clientHeight,D.doc umentElement. clientHeight)
);
If ($. browser. msie & $. browser. version> 6 & D. body. scrollHeight <$. viewHeight ()){
H = D. body. clientHeight;
}
If ($. browser. msie & document. compatMode = 'css1compat' & D. body. scrollHeight <$. viewHeight ()){
If ($. browser. version> 7 & $. browser. version <9 ){
} Else if ($. browser. version> 6 & $. browser. version <8 ){
}
Hsf-d.doc umentElement. clientHeight;
}
Return h;
}
/**
* Obtain the width of the canvas (that is, the browser view size when the browser content is insufficient)
*/
$. CanvasWidth = function (){
Var D = document, w = D. body. scrollWidth;
If (document. compatMode = 'css1compat '){
W=D.doc umentElement. scrollWidth;
} Else {
If ($. browser. msie & $. browser. version <= 6 & D. body. scrollWidth> $. viewWidth ()){
W=Math.max(Math.max(D.body.scrollWidth,D.doc umentElement. scrollWidth ),
Math.max(D.body.offsetWidth,D.doc umentElement. offsetWidth ),
Math.max(D.body.clientWidth,D.doc umentElement. clientWidth)
);
}
}
Return w;
}
/**
* Obtain the width of the canvas (that is, the browser view size when the browser content is insufficient)
*/
$. ScrollLeft = function (){
If (document. compatMode! = 'Css1compat' | ($. browser. msie & $. browser. version <= 6 )){
Return math.max((('body').scrollleft(,,document.doc umentElement. scrollLeft );
} Else {
Return $ ('body'). scrollLeft ();
}
}
/**
* Obtain the width of the canvas (that is, the browser view size when the browser content is insufficient)
*/
$. ScrollTop = function (){
If (document. compatMode! = 'Css1compat' | ($. browser. msie & $. browser. version <= 6 )){
Return Math. max ($ ('body'). scrollTop (), document.doc umentElement. scrollTop );
} Else {
Return $ ('body'). scrollTop ();
}
}
}) (JQuery );

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.