百度留言本js 大家可以参考下


window.onresize = baiduResizeDiv;
window.onerror = function(){}
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
var px = document.doctype?"px":0;
var scrollwidth = navigator.userAgent.indexOf("Firefox")>0?16:0;
var iframeheight = navigator.userAgent.indexOf("MSIE")>0?170-2:209-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{
divTop = parseInt(document.getElementById("eMeng").style.top,10);
divLeft = parseInt(document.getElementById("eMeng").style.left,10);
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
divWidth = 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 != 'BackCompat') {
scrollPosTop = document.documentElement.scrollTop;
scrollPosLeft = document.documentElement.scrollLeft;
docWidth = document.documentElement.clientWidth;
docHeight = document.documentElement.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;// divHeight
document.getElementById("eMeng").style.left = parseInt(scrollPosLeft,10) + docWidth - divWidth - scrollwidth + px;
document.getElementById("eMeng").style.visibility="visible";
objTimer = window.setInterval("baidu_move_div()",10);
}catch(e){}
}

function baiduResizeDiv()
{
i+=1;
try{
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
divWidth = 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 != 'BackCompat') {
scrollPosTop = document.documentElement.scrollTop;
scrollPosLeft = document.documentElement.scrollLeft;
docWidth = document.documentElement.clientWidth;
docHeight = document.documentElement.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 - divHeight + parseInt(scrollPosTop,10) + px;
document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(scrollPosLeft,10) - scrollwidth + px;
}catch(e){}
}

function baidu_move_div()
{

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 != 'BackCompat') {
scrollPosTop = document.documentElement.scrollTop;
scrollPosLeft = document.documentElement.scrollLeft;
docWidth = document.documentElement.clientWidth;
docHeight = document.documentElement.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 - divHeight + parseInt(scrollPosTop,10)))
{
window.clearInterval(objTimer);objTimer = window.setInterval("baiduResizeDiv()",1);
}
divTop = parseInt(document.getElementById("eMeng").style.top,10);
document.getElementById("eMeng").style.top = divTop - 1 + px;
}catch(e){}
}
function baiduMessbox(shape,color,userid){
var styles='position:absolute;top:0px;left:0px;z-index:99999;visibility:hidden;';
var copic='<img src="gbook/images/ico_'+color+'a.gif">';
if(shape>1) window.onload = baiduMsg;
else {styles='';copic=''}
var s;
if(shape==2) {
s='<div id=eMeng>'
+ '<table cellpadding="0" cellspacing="0">'
+'<tr>'
+'<td></td>'
+'</tr>'
+' <tr>'
+' <td><table cellspacing="0" cellpadding="0">'
+' <tr>'
+' <td rowspan="2" valign="bottom"><img src="gbook/images/ico'+(color+1)+'.gif"></td>'
+' <td>&nbsp;</td>'
+' </tr>'
+' <tr>'
+' <td align=right onDblClick="baidu_collapse(this.firstChild.nextSibling)"><a href="https://www.xxrblog.cn" target="_blank"><font color="#FFFFFF">乡下人blog xxrblog.cn</font></a> <img src="gbook/images/ico_'+color+'a.gif">'
+' </td>'
+' </tr>'
+' </table>'
+' </td>'
+' </tr>'
+''
+''
+''
+''
+''
+ '</table>'

+ '<iframe src="gbook/side.html?userid=' +userid+ '" frameborder="0"></iframe>'
+'<table cellspacing="0" cellpadding="3"><tr><td bgcolor="#FFFFFF"><table cellspacing="0" cellpadding="0" bgcolor="#FFFFFF"><tr><td></td></tr></table><table cellpadding="0" cellspacing="0"><tr><td valign="middle"><img src="https://www.jb51.net/gbook/images/kefu.jpg" /></td><td><table cellspacing="0" cellpadding="0"><tr><td valign="bottom">客服1</td><td valign="bottom">客服2</td></tr><tr><td colspan="2"><a href="https://www.jb51.net/tencent:/message/?uin=364738883&amp;Site=乡下人blog&amp;Menu=yes"><img src="https://www.jb51.net/gbook/images/qq.gif"/></a>&nbsp;<a href="https://www.jb51.net/msnim:chat?contact=24525533@163.com"><img alt="点击给我发MSN消息" src="https://www.jb51.net/gbook/images/msn.jpg"/></a></td></tr><tr><td colspan="2" valign="top">电话:13930042882</td></tr></table></td></tr></table><table cellspacing="0" cellpadding="0" bgcolor="#FFFFFF"><tr><td></td></tr></table><table cellpadding="0" cellspacing="0"></table></td></tr></table>'
+'</div>';
} else if(shape==3) {
s='<div id=eMeng>'
+' <table cellpadding="0" cellspacing="0">'
+' <tr>'
+' <td colspan="3" align=right onDblClick="baidu_collapse(this.firstChild.nextSibling)">留言板'+copic
+'</tr>'
+' </tr>'
+ '</table>'
+ '<iframe src="bottom.html?userid=' +userid+ '" frameborder="0"></iframe>'
+'</div>';
}
document.writeln(s);
}

baiduMessbox(2,1, 849620);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjygpf.html