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


Posted in Javascript onOctober 13, 2009
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);
Javascript 相关文章推荐
js 页面执行时间计算代码
Mar 04 Javascript
下载文件个别浏览器文件名乱码解决办法
Mar 19 Javascript
JS定时器实例
Apr 17 Javascript
js控制表单奇偶行样式的简单方法
Jul 31 Javascript
JavaScript中instanceof运算符的用法总结
Nov 19 Javascript
jQuery简单设置文本框回车事件的方法
Aug 01 Javascript
Angularjs实现mvvm式的选项卡示例代码
Sep 08 Javascript
jQuery倒计时代码(超简单)
Feb 27 Javascript
JavaScript转换数据库DateTime字段类型方法
Jun 27 Javascript
vue使用技巧及vue项目中遇到的问题
Jun 04 Javascript
详解使用Next.js构建服务端渲染应用
Jul 10 Javascript
layui 弹出删除确认界面的实例
Sep 06 Javascript
javascript hashtable实现代码
Oct 13 #Javascript
JavaScript 核心参考教程 内置对象
Oct 13 #Javascript
jQuery Ajax之load()方法
Oct 12 #Javascript
jQuery Ajax之$.get()方法和$.post()方法
Oct 12 #Javascript
JS 文件本身编码转换 图文教程
Oct 12 #Javascript
jQuery 行级解析读取XML文件(附源码)
Oct 12 #Javascript
jquery select选中的一个小问题
Oct 11 #Javascript
You might like
php获取当前网址url并替换参数或网址的方法
2010/06/06 PHP
支持中文的php加密解密类代码
2011/11/27 PHP
PHP多种序列化/反序列化的方法详解
2017/06/23 PHP
PHP中soap用法示例【SoapServer服务端与SoapClient客户端编写】
2018/12/25 PHP
用JavaScript玩转游戏物理(一)运动学模拟与粒子系统
2010/06/19 Javascript
jquery选择器大全 全面详解jquery选择器
2014/03/06 Javascript
js触发onchange事件的方法说明
2014/03/08 Javascript
jQuery中关于ScrollableGridPlugin.js(固定表头)插件的使用逐步解析
2014/07/17 Javascript
jQuery中ajax和post处理json的不同示例对比
2014/11/02 Javascript
JQuery Ajax WebService传递参数的简单实例
2016/11/02 Javascript
js实现简单的获取验证码按钮效果
2017/03/03 Javascript
解决Vue中mounted钩子函数获取节点高度出错问题
2018/05/18 Javascript
Vue页面跳转动画效果的实现方法
2018/09/23 Javascript
vue.js仿hover效果的实现方法示例
2019/01/28 Javascript
使用Vue实现简单计算器
2020/02/25 Javascript
详解Vue3中对VDOM的改进
2020/04/23 Javascript
JS指定音频audio在某个时间点进行播放
2020/11/28 Javascript
详细介绍Python语言中的按位运算符
2013/11/26 Python
python获取本机mac地址和ip地址的方法
2015/04/29 Python
python读取几个G的csv文件方法
2019/01/07 Python
详解用Python调用百度地图正/逆地理编码API
2020/07/02 Python
Python特殊属性property原理及使用方法解析
2020/10/09 Python
Pytorch 中的optimizer使用说明
2021/03/03 Python
CSS3自定义滚动条样式的示例代码
2017/08/21 HTML / CSS
荷兰音乐会和音乐剧门票订购网站:Topticketshop
2019/08/27 全球购物
一道SQL面试题
2012/12/31 面试题
工程预算与管理应届生求职信
2013/10/06 职场文书
乡下人家教学反思
2014/02/01 职场文书
五分钟演讲稿
2014/04/30 职场文书
贷款承诺书范文
2014/05/19 职场文书
超越自我演讲稿
2014/05/21 职场文书
班主任与学生安全责任书
2014/07/25 职场文书
考试作弊检讨书怎么写?
2014/12/21 职场文书
初中开学典礼新闻稿
2015/07/17 职场文书
品牌形象定位,全面分析
2019/07/23 职场文书
CocosCreator入门教程之网络通信
2021/04/16 Javascript