百度留言本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" align="absmiddle" class="ioc'+color+'" onClick="baidu_collapse(this)">';
if(shape>1) window.onload = baiduMsg;
else {styles='';copic=''}
var s;
if(shape==2) {
s='<div id=eMeng style="Z-INDEX:99999;LEFT:0px;POSITION:absolute;TOP:0px;VISIBILITY:hidden;">'
+ '<table width="216" border="0" cellpadding="0" cellspacing="0" class="" id="tab_'+(color+3)+'" style="border:0px;">'
+'<tr>'
+'<td align="right"></td>'
+'</tr>'
+' <tr>'
+' <td><table width="100%" border="0" cellspacing="0" cellpadding="0">'
+' <tr>'
+' <td width="32" rowspan="2" valign="bottom"><img src="gbook/images/ico'+(color+1)+'.gif"></td>'
+' <td> </td>'
+' </tr>'
+' <tr>'
+' <td align=right style="font-size:12px; background:url(gbook/images/bg_'+color+'.gif);line-height:21px;height:21px;border-top:1px solid #808080;border-right:1px solid #808080;padding-right:6px;color:#FFFFFF;" onDblClick="baidu_collapse(this.firstChild.nextSibling)"><a href="http://www.xxrblog.cn" target="_blank" style="text-decoration:none"><font color="#FFFFFF">乡下人blog xxrblog.cn</font></a> <img src="gbook/images/ico_'+color+'a.gif" align="absmiddle" class="ioc'+color+'" onClick="baidu_collapse(this)">'
+' </td>'
+' </tr>'
+' </table>'
+' </td>'
+' </tr>'
+''
+''
+''
+''
+''
+ '</table>'

+ '<iframe src="gbook/side.html?userid=' +userid+ '" width="216" height="' + iframeheight + '" frameborder="0" id="tab_c_iframe"></iframe>'
+'<table width="216" border="0" cellspacing="0" cellpadding="3" height="69" style="border-left-width:1px;border-left-style:solid;border-left-color:#000;border-right-width:1px;border-right-style:solid;border-right-color:#000;border-top-width:0;border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:#000000;"><tr><td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF"><tr><td style="height:3px;"></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0" style="background:#E70010;"><tr><td width="31%" align="center" valign="middle"><img src="gbook/images/kefu.jpg" width="50" height="55" /></td><td><table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px;color:#FFFFFF;"><tr><td width="38%" height="22" valign="bottom">客服1</td><td width="62%" valign="bottom">客服2</td></tr><tr><td height="22" colspan="2"><a href="tencent://message/?uin=364738883&Site=乡下人blog&Menu=yes"><img src="gbook/images/qq.gif" border="0"/></a> <a href="msnim:chat?contact=24525533@163.com"><img alt="点击给我发MSN消息" src="gbook/images/msn.jpg" border="0"/></a></td></tr><tr><td height="22" colspan="2" valign="top">电话:13930042882</td></tr></table></td></tr></table><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF"><tr><td style="height:3px;"></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0" style="background:#E70010;"></table></td></tr></table>'
+'</div>';
} else if(shape==3) {
s='<div id=eMeng style="width:100%;background:#FFFFFF;'+styles+'">'
+' <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #808080;" id="tab_'+color+'">'
+' <tr>'
+' <td colspan="3" align=right style="font-size:12px; background:url(gbook/images/bg_'+color+'.gif);line-height:19px;height:19px;padding-right:6px;color:#FFFFFF;" onDblClick="baidu_collapse(this.firstChild.nextSibling)">留言板'+copic
+'</tr>'
+' </tr>'
+ '</table>'
+ '<iframe src="bottom.html?userid=' +userid+ '" width="100%" height="85" frameborder="0" id="tab_c_iframe"></iframe>'
+'</div>';
}
document.writeln(s);
}

baiduMessbox(2,1, 849620);

(0)

相关推荐

  • 百度留言本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&quo

  • js判断是否按下了Shift键的方法

    本文实例讲述了js判断是否按下了Shift键的方法.分享给大家供大家参考.具体实现方法如下: 复制代码 代码如下: <html> <head> <title>使用js判断是否按下了Shift键</title> <script type="text/javascript"> function isKeyPressed(event) { if (event.shiftKey==1) { alert("shift被按下了&

  • JS实现文字向下滚动完整实例

    本文实例讲述了JS实现文字向下滚动的方法.分享给大家供大家参考.具体实现方法如下: 复制代码 代码如下: <!DOCTYPE> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>京东.淘宝晒单</title> <style> @charset "

  • JS实现从顶部下拉显示的带动画QQ客服特效代码

    本文实例讲述了JS实现从顶部下拉显示的带动画QQ客服特效代码.分享给大家供大家参考,具体如下: 这是一款动画版QQ在线客服代码,从网页顶部下拉出来的QQ客服,下滑结束后有弹性缓冲效果.在世界地图的映衬下,似乎一下子上升了品位.动画效果是由jq实现的,QQ客服的一些信息自己修改下,换成你自己的QQ,上传到网页就可用啦.注:在火狐台chrome浏览器中测试效果会更好. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-top-show-down-

  • JS实现灵巧的下拉导航效果代码

    本文实例讲述了JS实现灵巧的下拉导航效果代码.分享给大家供大家参考.具体如下: 这是一款基于JS实现下拉菜单,是一款灵巧的网站导航条,支持二级显示,向下滑动显示,经典的下拉菜单,JS和CSS共同编写实现,Li菜单列表风格,便于修改,兼容各大主流浏览器,相信你也会喜欢的. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-down-nav-blue-menu-style-codes/ 具体代码如下: <!DOCTYPE html PUBLIC

  • 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

  • JS实现点击下拉菜单把选择的内容同步到input输入框内的实例

    最近博主在边学flask边写测试平台,碰到一个比较常用的场景如下图所示 这里有一个输入框组,下拉菜单里面有3个选项,还有一个输入框,代码是用 bootstrap写的,代码也给大家贴出来 <div class="input-group-btn"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"

  • js动态设置select下拉菜单的默认选中项实例

    利用javascript设置select下拉菜单的选中项. 代码实例如下: <!--js动态设置select下拉菜单的默认选中项--> <html> <head> <title>下拉菜单</title> <script type="text/javascript"> window.onload=function(){ var osel=document.getElementById("selID"

  • JS实现鼠标按下拖拽效果

    原生JS实现鼠标按下拖拽效果,供大家参考,具体内容如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv=&qu

  • 基于JS快速实现导航下拉菜单动画效果附源码下载

    这是一个带变形动画特效的下拉导航菜单特效.该导航菜单在菜单项之间切换时,下拉菜单会快速的根据菜单内容的大小来动态变形,显示合适的下拉菜单大小,效果非常棒. 快速的导航下拉菜单动画效果如下所示: 效果演示         源码下载 HTML 该导航菜单的HTML结构如下: <header class="cd-morph-dropdown"> <a href="#0" class="nav-trigger">Open Nav&

随机推荐