百度留言本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 相关文章推荐
ExtJS GTGrid 简单用户管理
Jul 01 Javascript
基于jQuery的history历史记录插件
Dec 11 Javascript
基于JQuery实现的类似购物商城的购物车
Dec 06 Javascript
推荐9款炫酷的基于jquery的页面特效
Dec 07 Javascript
浅谈JavaScript函数节流
Dec 09 Javascript
使用iojs的jsdom库实现同步系统时间
Apr 20 Javascript
vue-dialog的弹出层组件
May 25 Javascript
详解angular ui-grid之过滤器设置
Jun 07 Javascript
JS实现新建文件夹功能
Jun 17 Javascript
解决vue接口数据赋值给data没有反应的问题
Aug 27 Javascript
vue-cli3搭建项目的详细步骤
Dec 05 Javascript
jQuery实现数字自动增加或者减少的动画效果示例
Dec 11 jQuery
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 截取字符串函数整理(支持gb2312和utf-8)
2010/02/16 PHP
php Ubb代码编辑器函数代码
2012/07/05 PHP
php学习之function的用法
2012/07/14 PHP
LotusPhp笔记之:基于ObjectUtil组件的使用分析
2013/05/06 PHP
php的ajax简单实例
2014/02/27 PHP
PHP+MySQL插入操作实例
2015/01/21 PHP
配置Nginx+PHP的正确思路与过程
2016/05/10 PHP
PHP中用mysqli面向对象打开连接关闭mysql数据库的方法
2016/11/05 PHP
jqPlot Option配置对象详解
2009/07/25 Javascript
extjs grid设置某列背景颜色和字体颜色的方法
2010/09/03 Javascript
javaScript矢量图表库-gRaphael几行代码实现精美的条形图/饼图/点图/曲线图
2013/01/09 Javascript
alert出数组中的随即值代码
2014/09/25 Javascript
JS获取复选框的值,并传递到后台的实现方法
2016/05/30 Javascript
jQGrid Table操作列中点击【操作】按钮弹出按钮层的实现代码
2016/12/05 Javascript
jQuery 中msgTips 顶部弹窗效果实现代码
2017/08/14 jQuery
vue打包后显示空白正确处理方法
2017/11/01 Javascript
vue将单页面改造成多页面应用的方法
2018/11/25 Javascript
JS实现数组去重,显示重复元素及个数的方法示例
2019/01/21 Javascript
详解async/await 异步应用的常用场景
2019/05/13 Javascript
JS实现网页时钟特效
2020/03/25 Javascript
python实现电子词典
2020/04/23 Python
Python使用cx_Oracle模块操作Oracle数据库详解
2018/05/07 Python
Python后台开发Django的教程详解(启动)
2019/04/08 Python
python 读写文件包含多种编码格式的解决方式
2019/12/20 Python
tensorflow之并行读入数据详解
2020/02/05 Python
Python pip安装第三方库实现过程解析
2020/07/09 Python
Python colormap库的安装和使用详情
2020/10/06 Python
泰国排名第一的家居用品中心:HomePro
2020/11/18 全球购物
如何进行Linux分区优化
2013/02/12 面试题
财务管理专业毕业生求职信范文
2013/09/21 职场文书
自动化专业毕业生自荐信
2013/11/01 职场文书
水污染治理工程专业求职信
2014/06/14 职场文书
公诉意见书范文
2015/06/05 职场文书
mysql 数据插入优化方法之concurrent_insert
2021/07/01 MySQL
Nginx下SSL证书安装部署步骤介绍
2021/12/06 Servers
Win11怎么解除儿童账号限制?Win11解除微软儿童账号限制方法
2022/07/07 数码科技