Baidu message book js for your reference _ javascript skills

Source: Internet
Author: User
For details about Baidu message book js, refer. The Code is as follows:


Window. onresize = baiduResizeDiv;
Window. onerror = function (){}
Var pTop, pLeft, pWidth, pHeight, docHeight, docWidth, objTimer, I = 0;
Var px = document.doc type? "Px": 0;
Var scrollwidth = navigator. userAgent. indexOf ("Firefox")> 0? 16: 0;
Var iframeheight = navigator. userAgent. indexOf ("MSIE")> 0? 170--2;
String. prototype. Trim = function () {return this. replace (/^ \ s + | \ s + $/g ,"");}
Function baidu_collapse (obj ){
Ct = document. getElementById ('tab _ c_iframe ');
If (ct. style. display = "none "){
Ct. style. display = "";
Obj. src = obj. src. replace ("B .gif", "a.gif ");
} Else {
Ct. style. display = "none ";
Obj. src = obj. src. replace ("a.gif", "B .gif ");
}
BaiduResizeDiv ();
}

Function baiduMsg ()
{
Try {
PTop = parseInt (document. getElementById ("eMeng"). style. top, 10 );
PLeft = parseInt (document. getElementById ("eMeng"). style. left, 10 );
PHeight = parseInt (document. getElementById ("eMeng"). offsetHeight, 10 );
PWidth = parseInt (document. getElementById ("eMeng"). offsetWidth, 10 );

Var scrollPosTop, scrollPosLeft, docWidth, docHeight;
If (typeof window. pageYOffset! = 'Undefined '){
ScrollPosTop = window. pageYOffset;
ScrollPosLeft = window. pageXOffset;
DocWidth = window. innerWidth;
DocHeight = window. innerHeight;
} Else if (typeof document. compatMode! = 'Undefined' & document. compatMode! = 'Background '){
ScrollPosTop = document.doc umentElement. scrollTop;
ScrollPosLeft = document.doc umentElement. scrollLeft;
DocWidth = document.doc umentElement. clientWidth;
DocHeight = document.doc umentElement. clientHeight;
} Else if (typeof document. body! = 'Undefined '){
ScrollPosTop = document. body. scrollTop;
ScrollPosLeft = document. body. scrollLeft;
DocWidth = document. body. clientWidth;
DocHeight = document. body. clientHeight;
}

Document. getElementById ("eMeng"). style. top = parseInt (scrollPosTop, 10) + docHeight + 10 + px; // pHeight
Document. getElementById ("eMeng"). style. left = parseInt (scrollPosLeft, 10) + docWidth-pWidth-scrollwidth + px;
Document. getElementById ("eMeng"). style. visibility = "visible ";
ObjTimer = window. setInterval ("baidu_move_p ()", 10 );
} Catch (e ){}
}

Function baiduResizeDiv ()
{
I + = 1;
Try {
PHeight = parseInt (document. getElementById ("eMeng"). offsetHeight, 10 );
PWidth = parseInt (document. getElementById ("eMeng"). offsetWidth, 10 );

Var scrollPosTop, scrollPosLeft, docWidth, docHeight;
If (typeof window. pageYOffset! = 'Undefined '){
ScrollPosTop = window. pageYOffset;
ScrollPosLeft = window. pageXOffset;
DocWidth = window. innerWidth;
DocHeight = window. innerHeight;
} Else if (typeof document. compatMode! = 'Undefined' & document. compatMode! = 'Background '){
ScrollPosTop = document.doc umentElement. scrollTop;
ScrollPosLeft = document.doc umentElement. scrollLeft;
DocWidth = document.doc umentElement. clientWidth;
DocHeight = document.doc umentElement. clientHeight;
} Else if (typeof document. body! = 'Undefined '){
ScrollPosTop = document. body. scrollTop;
ScrollPosLeft = document. body. scrollLeft;
DocWidth = document. body. clientWidth;
DocHeight = document. body. clientHeight;
}

Document. getElementById ("eMeng"). style. top = docHeight-pHeight + parseInt (scrollPosTop, 10) + px;
Document. getElementById ("eMeng"). style. left = docWidth-pWidth + parseInt (scrollPosLeft, 10)-scrollwidth + px;
} Catch (e ){}
}

Function baidu_move_p ()
{

Var scrollPosTop, scrollPosLeft, docWidth, docHeight;
If (typeof window. pageYOffset! = 'Undefined '){
ScrollPosTop = window. pageYOffset;
ScrollPosLeft = window. pageXOffset;
DocWidth = window. innerWidth;
DocHeight = window. innerHeight;
} Else if (typeof document. compatMode! = 'Undefined' & document. compatMode! = 'Background '){
ScrollPosTop = document.doc umentElement. scrollTop;
ScrollPosLeft = document.doc umentElement. scrollLeft;
DocWidth = document.doc umentElement. clientWidth;
DocHeight = document.doc umentElement. clientHeight;
} Else if (typeof document. body! = 'Undefined '){
ScrollPosTop = document. body. scrollTop;
ScrollPosLeft = document. body. scrollLeft;
DocWidth = document. body. clientWidth;
DocHeight = document. body. clientHeight;
}

Try {
If (parseInt (document. getElementById ("eMeng"). style. top, 10) <= (docHeight-pHeight + parseInt (scrollPosTop, 10 )))
{
Window. clearInterval (objTimer); objTimer = window. setInterval ("baiduResizeDiv ()", 1 );
}
PTop = parseInt (document. getElementById ("eMeng"). style. top, 10 );
Document. getElementById ("eMeng"). style. top = pTop-1 + px;
} Catch (e ){}
}
Function baiduMessbox (shape, color, userid ){
Var styles = 'position: absolute; top: 0px; left: 0px; z-index: 99999; visibility: hidden ;';
Var copic = '';
If (shape> 1) window. onload = baiduMsg;
Else {styles = ''; copic = ''}
Var s;
If (shape = 2 ){
S ='

'
+'













'+' '+' '+' '+' '+' '+' '+''+''+''+''+''+'








'+' '+' '+' '+' '+' '+' '+' '+'
Country blog xxrblog.cn'
+'
'
+'
'

+''
+'
Customer Service 1 Customer Service 2
Tel: 13930042882
'
+'

';
} Else if (shape = 3 ){
S ='

'
+'





'+' '+' '+''+'
Message board '+ copic
+'
'
+''
+'

';
}
Document. writeln (s );
}

BaiduMessbox (849620 );
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.