Ajax Blog 用到的几个函数
人气:0
类名:AJAX
/*类名:AJAX
创建方法:var ajaxobj=new AJAX;,如果创建失败则返回false
属性:method - 请求方法,字符串,POST或者GET,默认为POST
url - 请求URL,字符串,默认为空
async - 是否异步,true为异步,false为同步,默认为true
content - 请求的内容,如果请求方法为POST需要设定此属性,默认为空
backtext - 默认true当backtext=true时返回XMLHttp.responseText为false时返回XMLHttp.responseXML
gettext - 返回值
callback - 回调函数,即返回响应内容时调用的函数,默认为直接返回,回调函数有一个参数为XMLHttpRequest对象,即定义回调函数时要这样:function mycallback(xmlobj)
方法:send() - 发送请求,无参数
*/
function AJAX() {
var XMLHttp = false;
var ObjSelf;
ObjSelf=this;
try { XMLHttp=new XMLHttpRequest; }
catch(e) {
try { XMLHttp=new ActiveXObject("MSXML2.XMLHttp"); }
catch(e2) {
try { XMLHttp=new ActiveXObject("Microsoft.XMLHttp"); }
catch(e3) { XMLHttp=false; }
}
}
if (!XMLHttp) return false;
this.method="POST";
this.url=""
this.url += (this.url.indexOf("?") >= 0) ? "&nowtime=" + new Date().getTime():"?nowtime=" + new Date().getTime();
this.async=true;
this.data="";
ObjSelf.loadid=""
this.backtext=true
this.callback=function() {return;}
this.send=function() {
if(!this.method||!this.url||!this.async) return false;
XMLHttp.open (this.method, this.url, this.async);
if(this.method=="POST"){
XMLHttp.setRequestHeader("Content-Length",(this.data).length);
XMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
XMLHttp.onreadystatechange=function() {
if(XMLHttp.readyState==4) {
//alert(ObjSelf.loadid);
if (ObjSelf.loadid!="") $CS(ObjSelf.loadid,"none");
//window.status="";
if(XMLHttp.status==200) {
ObjSelf.callback();
}
}
else {
if (ObjSelf.loadid!="") $CS(ObjSelf.loadid,"block");
//window.status="状态:["+XMLHttp.readyState+"]正在加载......";
}
}
if(this.method=="POST") XMLHttp.send(this.data);
else XMLHttp.send(null);
}
this.gettext=function(){
if(XMLHttp.readyState==4) {
if(XMLHttp.status==200) {
if (this.backtext==true){
return XMLHttp.responseText;
}else{
return XMLHttp.responseXML;
}
}
}
}
}
blog.js
//打开和关闭左栏
function $SHleft(id){
if($(id).style.display=='none'){
$(id).style.display='block';
$("content").style.width='550px';
$F("sh","隐藏左栏");
}
else{
$(id).style.display='none';
$("content").style.width='750px';
$F("sh","打开左栏");
}
}
//打开和关闭评论
function $PL(id,plid){
if($("rp"+id).style.display=='none'){
$("rp"+id).style.display='block';
$F("pl"+id,"隐藏评论");
replycon(id,"rp"+id);
}
else{
$("rp"+id).style.display='none';
$F("pl"+id,"查看评论");
}
}
//显示日志
function show(id,pageid,rq){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=show&sid="+id+"&rq="+escape(rq)+"&page="+pageid;
ajaxobj.callback=function(){
$F("bkcon",ajaxobj.gettext());
}
ajaxobj.send();
}
//显示日志分类列表
function board(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=board";
ajaxobj.callback=function(){
$F("blogcon",ajaxobj.gettext());
}
ajaxobj.send();
}
//取得评论内容
function replycon(rid,rpid){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=replycon&rid="+rid;
ajaxobj.callback=function(){
$F(rpid,ajaxobj.gettext());
}
ajaxobj.send();
}
//取得评论数量
function plnum(rid){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=plnum&rid="+rid;
ajaxobj.callback=function(){
$F("plnum"+rid,ajaxobj.gettext());
}
ajaxobj.send();
}
//加载发表评论表单
function rform(rid){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=rform&rid="+rid;
ajaxobj.callback=function(){
$F("plform"+rid,ajaxobj.gettext());
}
ajaxobj.send();
}
//添加评论内容
function savepl(rid){
var ajaxobj=new AJAX();
ajaxobj.method="POST";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=savepl&";
ajaxobj.data="rid="+rid+"&username="+escape($("username"+rid).value)+"&con="+escape($("con"+rid).value);
ajaxobj.callback=function(){
$F("tjpl"+rid,ajaxobj.gettext());
if (ajaxobj.gettext().indexOf("评论已提交成功")>=0) {
//如果评论提交成功则关闭表单、重新取得评论的数量。关闭成功提示信息
$CS("rform"+rid,"none");
plnum(rid);
pltjid="pltjsuc"+rid;
setTimeout('$CS(pltjid,"none")',1000);
}
}
ajaxobj.send();
}
//显示日历
function rl(ReqDate){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=rl&ReqDate="+ReqDate;
ajaxobj.callback=function(){
$F("calendarcon",ajaxobj.gettext());
}
ajaxobj.send();
}
//显示留言表单
function gb(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=gb";
ajaxobj.callback=function(){
$F("gbform",ajaxobj.gettext());
}
ajaxobj.send();
}
//提交留言
function savegb(){
var gbusername=$("gbusername").value;
var gbemail=$("gbemail").value;
var gbcon=$("gbcon").value;
//alert($("gbusername").value);
//alert($("gbemail").value);
//alert($("gbcon").value);
//return false;
if (gbusername==""){
$CS("gberr","block");
$F("gberr","请署上你的大名");
setTimeout('$CS("gberr","none")',2000);
return false;
}
if (gbemail==""){
$CS("gberr","block");
$F("gberr","请写上你的邮箱");
setTimeout('$CS("gberr","none")',2000);
return false;
}
if (gbcon==""){
$CS("gberr","block");
$F("gberr","请发表你的意见");
setTimeout('$CS("gberr","none")',2000);
return false;
}
var ajaxobj=new AJAX();
ajaxobj.method="POST";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=addgb&";
ajaxobj.data="username="+escape(gbusername)+"&email="+escape(gbemail)+"&con="+escape(gbcon);
ajaxobj.send();
ajaxobj.callback=function(){
if (ajaxobj.gettext().indexOf("成功")>=0) {
$SHwin("gb");
showgb(1);
}
}
}
//显示留言
function showgb(pageid){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=showgb&page="+pageid;
ajaxobj.callback=function(){
$F("bkcon",ajaxobj.gettext());
}
ajaxobj.send();
}
//显示聊天内容
function showmsg(){
chatmsg.scrollTop=chatmsg.scrollHeight;
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=show";
ajaxobj.callback=function(){
$("chatmsg").innerHTML+=ajaxobj.gettext();
}
ajaxobj.send();
}
//显示聊天输入框
function showadd(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=showadd";
ajaxobj.callback=function(){
$F("addform",ajaxobj.gettext());
}
ajaxobj.send();
}
//用户登陆聊天室
function login(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=login&user="+$("user").value;
ajaxobj.send();
ajaxobj.callback=function(){
if (ajaxobj.gettext()!=""){
$CS("chaterr","block");
$F("chaterr",ajaxobj.gettext());
setTimeout('$CS("chaterr","none")',2000);
}
}
setTimeout('showadd()',1000);
}
//开始进行聊天
function addmsg(){
var ajaxobj=new AJAX();
ajaxobj.method="POST";
ajaxobj.url="chat.asp?"
ajaxobj.data="act=addmsg&con="+escape($("con").value)+"&touser="+escape($("touser").value)+"&sl="+escape($("sl").checked);
ajaxobj.send();
ajaxobj.callback=function(){
if (ajaxobj.gettext()!=""){
$CS("chaterr","block");
$F("chaterr",ajaxobj.gettext());
setTimeout('$CS("chaterr","none")',2000);
}
}
setTimeout('showmsg()',1000);
}
//用户退出聊天室
function logout(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=logout";
ajaxobj.send();
setTimeout('showadd()',1000);
}
//显示在线用户列表
function showonline(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=showonline";
ajaxobj.callback=function(){
$F("showonlineinfo",ajaxobj.gettext());
}
ajaxobj.send();
}
//把某用户踢出聊天室
function td(username){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=td&user="+escape(username)+"&pws="+escape($("pws").value);
ajaxobj.send();
ajaxobj.callback=function(){
if (ajaxobj.gettext()!=""){
$CS("chaterr","block");
$F("chaterr",ajaxobj.gettext());
setTimeout('$CS("chaterr","none")',2000);
}
}
setTimeout('showonline()',1000);
}
//查看用户IP所在物理地址
function ip(data){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=getip&ip="+escape(data);
ajaxobj.callback=function(){
$F("ipinfo",ajaxobj.gettext());
}
ajaxobj.send();
}
//删除多长时间不活动的用户和删除超过多长时间的聊天记录
function delmsg(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=delmsg";
ajaxobj.send();
}
//点击某用户进行聊天
function who(whoname){
$("touser").value=whoname;
$("con").focus();
}
//点击某用户进行聊天并自动关闭在线层
function who2(whoname){
$("touser").value=whoname;
$CS("showonlineinfo","none");
$("con").focus();
}
//双击复制用户聊天内容到输入框
function copycon(id){
$("con").focus();
$("con").value+=$("con"+id).innerText
}
//初始化
function initchat(){
showmsg();
showadd();
}
//几秒钟提取一次聊天内容
window.setInterval("showmsg()",3000);
//几秒钟执行是否有符合规定的用户或聊天内容需要删除
window.setInterval("delmsg()",60000);
//自动固定窗口大小
//用回车或Ctrl+回车可以直接发送信息
function ctlent(){
if(window.event.keyCode==13||(event.ctrlKey && window.event.keyCode==13)){
addmsg();$("con").value='';
}
}
common.js
drag.js主要用于移动
var x0=0,y0=0,x1=0,y1=0;
var offx=6,offy=6;
var moveable=false;
var normal='#C6E7FF'; //正常时的背景颜色
var index=10000; //z-index;
//开始拖动;
function startDrag(obj)
{
if(event.button==1)
{
obj.setCapture(); //锁定标题栏;
var win = obj.parentNode; //定义对象;
x0 = event.clientX; //记录鼠标和层位置;
y0 = event.clientY;
x1 = parseInt(win.style.left);
y1 = parseInt(win.style.top);
moveable = true;
}
}
//拖动;
function drag(obj)
{
if(moveable)
{
var win = obj.parentNode;
win.style.left = x1 + event.clientX - x0;
win.style.top = y1 + event.clientY - y0;
}
}
//停止拖动;
function stopDrag(obj)
{
if(moveable)
{
obj.releaseCapture();
moveable = false;
}
}
//获得焦点;
function getFocus(obj)
{
if(obj.style.zIndex!=index)
{
index = index + 2;
var idx = index;
obj.style.zIndex=idx;
obj.nextSibling.style.zIndex=idx-1;
}
}
//最小化;
function min(obj)
{
var win=obj.parentNode.parentNode.parentNode;
var msg=win.childNodes;
var flg=msg(1).style.display;
if(flg=="none")
{
msg(1).style.display = "block";
obj.src= "images/opentriangle.gif";
}else{
msg(1).style.display = "none";
obj.src= "images/TRIANGLE.GIF";
}
}
//创建一个对象;
function xWin(id,w,h,l,t,tit,msg)
{
index = index+2;
this.id = id;
this.width = w;
this.height = h;
this.left = l;
this.top = t;
this.zIndex = index;
this.title = tit;
this.message = msg;
this.obj = null;
this.bulid = bulid;
this.bulid();
}
//初始化;
function bulid()
{
var str = ""
+ "<div id=xMsg" + this.id + " "
+ "style='"
+ "z-index:" + this.zIndex + ";"
+ "width:" + this.width + ";"
+ "left:" + this.left + ";"
+ "top:" + this.top + ";"
+ "background-color:#fff;"
+ "color:#000;"
+ "font-size:14px;"
+ "position:absolute;"
+ "display:none;"
+ "border:#6BC3FF 1px solid ;'"
+ "onmousedown='getFocus(this)'>"
+ "<div "
+ "style='"
+ "background-color:" + normal + ";"
+ "width:" + (this.width+5) + ";"
+ "line-height:26px;cursor:move;border:1px #ccc solid;"
+ "margin:1px;vertical-align:middle"
+ "' "
+ "onmousedown='startDrag(this)' "
+ "onmouseup='stopDrag(this)' "
+ "onmousemove='drag(this)' "
+ "ondblclick='min(this.childNodes[1])'"
+ ">"
+ "<span style='float:left;width:50%;text-align:left;padding-left:3px;font-weight:bold;'>" + this.title +""+"</span>"
+ "<span style='float:right;width:47%;text-align:right;padding-right:3px;padding-top:5px;'> "
+"<img src='images/opentriangle.GIF' onclick='min(this)' style='cursor:pointer;'/> "
+"<img src='images/CloseBtn.gif' onclick='$SHwin(\""+this.id+"\")' style='cursor:pointer;'/></span>"
+ "</div>"
+ "<div style='"
+ "width:100%;"
+ "height:" + this.height + ";"
+ "background-color:white;"
+ "line-height:14px;"
+ "word-break:break-all;"
+ "padding:3px;"
+ "'>" + this.message + "</div>"
+ "</div>"
document.body.insertAdjacentHTML("beforeEnd",str);
}
function $SHwin(id){
if(document.getElementById("xMsg"+id).style.display=='none'){
document.getElementById("xMsg"+id).style.display='block';
}
else{
document.getElementById("xMsg"+id).style.display='none';
}
}
复制代码 代码如下:
/*类名:AJAX
创建方法:var ajaxobj=new AJAX;,如果创建失败则返回false
属性:method - 请求方法,字符串,POST或者GET,默认为POST
url - 请求URL,字符串,默认为空
async - 是否异步,true为异步,false为同步,默认为true
content - 请求的内容,如果请求方法为POST需要设定此属性,默认为空
backtext - 默认true当backtext=true时返回XMLHttp.responseText为false时返回XMLHttp.responseXML
gettext - 返回值
callback - 回调函数,即返回响应内容时调用的函数,默认为直接返回,回调函数有一个参数为XMLHttpRequest对象,即定义回调函数时要这样:function mycallback(xmlobj)
方法:send() - 发送请求,无参数
*/
function AJAX() {
var XMLHttp = false;
var ObjSelf;
ObjSelf=this;
try { XMLHttp=new XMLHttpRequest; }
catch(e) {
try { XMLHttp=new ActiveXObject("MSXML2.XMLHttp"); }
catch(e2) {
try { XMLHttp=new ActiveXObject("Microsoft.XMLHttp"); }
catch(e3) { XMLHttp=false; }
}
}
if (!XMLHttp) return false;
this.method="POST";
this.url=""
this.url += (this.url.indexOf("?") >= 0) ? "&nowtime=" + new Date().getTime():"?nowtime=" + new Date().getTime();
this.async=true;
this.data="";
ObjSelf.loadid=""
this.backtext=true
this.callback=function() {return;}
this.send=function() {
if(!this.method||!this.url||!this.async) return false;
XMLHttp.open (this.method, this.url, this.async);
if(this.method=="POST"){
XMLHttp.setRequestHeader("Content-Length",(this.data).length);
XMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
XMLHttp.onreadystatechange=function() {
if(XMLHttp.readyState==4) {
//alert(ObjSelf.loadid);
if (ObjSelf.loadid!="") $CS(ObjSelf.loadid,"none");
//window.status="";
if(XMLHttp.status==200) {
ObjSelf.callback();
}
}
else {
if (ObjSelf.loadid!="") $CS(ObjSelf.loadid,"block");
//window.status="状态:["+XMLHttp.readyState+"]正在加载......";
}
}
if(this.method=="POST") XMLHttp.send(this.data);
else XMLHttp.send(null);
}
this.gettext=function(){
if(XMLHttp.readyState==4) {
if(XMLHttp.status==200) {
if (this.backtext==true){
return XMLHttp.responseText;
}else{
return XMLHttp.responseXML;
}
}
}
}
}
blog.js
复制代码 代码如下:
//打开和关闭左栏
function $SHleft(id){
if($(id).style.display=='none'){
$(id).style.display='block';
$("content").style.width='550px';
$F("sh","隐藏左栏");
}
else{
$(id).style.display='none';
$("content").style.width='750px';
$F("sh","打开左栏");
}
}
//打开和关闭评论
function $PL(id,plid){
if($("rp"+id).style.display=='none'){
$("rp"+id).style.display='block';
$F("pl"+id,"隐藏评论");
replycon(id,"rp"+id);
}
else{
$("rp"+id).style.display='none';
$F("pl"+id,"查看评论");
}
}
//显示日志
function show(id,pageid,rq){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=show&sid="+id+"&rq="+escape(rq)+"&page="+pageid;
ajaxobj.callback=function(){
$F("bkcon",ajaxobj.gettext());
}
ajaxobj.send();
}
//显示日志分类列表
function board(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=board";
ajaxobj.callback=function(){
$F("blogcon",ajaxobj.gettext());
}
ajaxobj.send();
}
//取得评论内容
function replycon(rid,rpid){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=replycon&rid="+rid;
ajaxobj.callback=function(){
$F(rpid,ajaxobj.gettext());
}
ajaxobj.send();
}
//取得评论数量
function plnum(rid){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=plnum&rid="+rid;
ajaxobj.callback=function(){
$F("plnum"+rid,ajaxobj.gettext());
}
ajaxobj.send();
}
//加载发表评论表单
function rform(rid){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=rform&rid="+rid;
ajaxobj.callback=function(){
$F("plform"+rid,ajaxobj.gettext());
}
ajaxobj.send();
}
//添加评论内容
function savepl(rid){
var ajaxobj=new AJAX();
ajaxobj.method="POST";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=savepl&";
ajaxobj.data="rid="+rid+"&username="+escape($("username"+rid).value)+"&con="+escape($("con"+rid).value);
ajaxobj.callback=function(){
$F("tjpl"+rid,ajaxobj.gettext());
if (ajaxobj.gettext().indexOf("评论已提交成功")>=0) {
//如果评论提交成功则关闭表单、重新取得评论的数量。关闭成功提示信息
$CS("rform"+rid,"none");
plnum(rid);
pltjid="pltjsuc"+rid;
setTimeout('$CS(pltjid,"none")',1000);
}
}
ajaxobj.send();
}
//显示日历
function rl(ReqDate){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=rl&ReqDate="+ReqDate;
ajaxobj.callback=function(){
$F("calendarcon",ajaxobj.gettext());
}
ajaxobj.send();
}
//显示留言表单
function gb(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=gb";
ajaxobj.callback=function(){
$F("gbform",ajaxobj.gettext());
}
ajaxobj.send();
}
//提交留言
function savegb(){
var gbusername=$("gbusername").value;
var gbemail=$("gbemail").value;
var gbcon=$("gbcon").value;
//alert($("gbusername").value);
//alert($("gbemail").value);
//alert($("gbcon").value);
//return false;
if (gbusername==""){
$CS("gberr","block");
$F("gberr","请署上你的大名");
setTimeout('$CS("gberr","none")',2000);
return false;
}
if (gbemail==""){
$CS("gberr","block");
$F("gberr","请写上你的邮箱");
setTimeout('$CS("gberr","none")',2000);
return false;
}
if (gbcon==""){
$CS("gberr","block");
$F("gberr","请发表你的意见");
setTimeout('$CS("gberr","none")',2000);
return false;
}
var ajaxobj=new AJAX();
ajaxobj.method="POST";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=addgb&";
ajaxobj.data="username="+escape(gbusername)+"&email="+escape(gbemail)+"&con="+escape(gbcon);
ajaxobj.send();
ajaxobj.callback=function(){
if (ajaxobj.gettext().indexOf("成功")>=0) {
$SHwin("gb");
showgb(1);
}
}
}
//显示留言
function showgb(pageid){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.loadid="loadnews";
ajaxobj.url="lib.asp?action=showgb&page="+pageid;
ajaxobj.callback=function(){
$F("bkcon",ajaxobj.gettext());
}
ajaxobj.send();
}
复制代码 代码如下:
//显示聊天内容
function showmsg(){
chatmsg.scrollTop=chatmsg.scrollHeight;
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=show";
ajaxobj.callback=function(){
$("chatmsg").innerHTML+=ajaxobj.gettext();
}
ajaxobj.send();
}
//显示聊天输入框
function showadd(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=showadd";
ajaxobj.callback=function(){
$F("addform",ajaxobj.gettext());
}
ajaxobj.send();
}
//用户登陆聊天室
function login(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=login&user="+$("user").value;
ajaxobj.send();
ajaxobj.callback=function(){
if (ajaxobj.gettext()!=""){
$CS("chaterr","block");
$F("chaterr",ajaxobj.gettext());
setTimeout('$CS("chaterr","none")',2000);
}
}
setTimeout('showadd()',1000);
}
//开始进行聊天
function addmsg(){
var ajaxobj=new AJAX();
ajaxobj.method="POST";
ajaxobj.url="chat.asp?"
ajaxobj.data="act=addmsg&con="+escape($("con").value)+"&touser="+escape($("touser").value)+"&sl="+escape($("sl").checked);
ajaxobj.send();
ajaxobj.callback=function(){
if (ajaxobj.gettext()!=""){
$CS("chaterr","block");
$F("chaterr",ajaxobj.gettext());
setTimeout('$CS("chaterr","none")',2000);
}
}
setTimeout('showmsg()',1000);
}
//用户退出聊天室
function logout(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=logout";
ajaxobj.send();
setTimeout('showadd()',1000);
}
//显示在线用户列表
function showonline(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=showonline";
ajaxobj.callback=function(){
$F("showonlineinfo",ajaxobj.gettext());
}
ajaxobj.send();
}
//把某用户踢出聊天室
function td(username){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=td&user="+escape(username)+"&pws="+escape($("pws").value);
ajaxobj.send();
ajaxobj.callback=function(){
if (ajaxobj.gettext()!=""){
$CS("chaterr","block");
$F("chaterr",ajaxobj.gettext());
setTimeout('$CS("chaterr","none")',2000);
}
}
setTimeout('showonline()',1000);
}
//查看用户IP所在物理地址
function ip(data){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=getip&ip="+escape(data);
ajaxobj.callback=function(){
$F("ipinfo",ajaxobj.gettext());
}
ajaxobj.send();
}
//删除多长时间不活动的用户和删除超过多长时间的聊天记录
function delmsg(){
var ajaxobj=new AJAX();
ajaxobj.method="GET";
ajaxobj.url="chat.asp?act=delmsg";
ajaxobj.send();
}
//点击某用户进行聊天
function who(whoname){
$("touser").value=whoname;
$("con").focus();
}
//点击某用户进行聊天并自动关闭在线层
function who2(whoname){
$("touser").value=whoname;
$CS("showonlineinfo","none");
$("con").focus();
}
//双击复制用户聊天内容到输入框
function copycon(id){
$("con").focus();
$("con").value+=$("con"+id).innerText
}
//初始化
function initchat(){
showmsg();
showadd();
}
//几秒钟提取一次聊天内容
window.setInterval("showmsg()",3000);
//几秒钟执行是否有符合规定的用户或聊天内容需要删除
window.setInterval("delmsg()",60000);
//自动固定窗口大小
//用回车或Ctrl+回车可以直接发送信息
function ctlent(){
if(window.event.keyCode==13||(event.ctrlKey && window.event.keyCode==13)){
addmsg();$("con").value='';
}
}
common.js
复制代码 代码如下:
//禁止使用右键
function Click(){ alert('不许动,哈哈哈哈!'); window.event.returnValue=false; } document.oncontextmenu=Click;
function $showdiv(objtitid,objconid){
if($(objconid).style.display=="none"){
$(objconid).style.display="block";
var Ka=navigator.userAgent.toLowerCase();
var rt=Ka.indexOf("opera")!=-1;
var r=Ka.indexOf("msie")!=-1&&(document.all&&!rt);
if(r){
document.attachEvent("onmousedown",function (){$(objconid).style.display="none";document.onmousedown = null; } );
$(objtitid).attachEvent("onmousedown",function(){event.cancelBubble=true;});
$(objconid).attachEvent("onmousedown",function(){event.cancelBubble=true;});
} else {
document.addEventListener("onmousedown",function (){$(objconid).style.display="none";document.onmousedown = null; },false);
$(objtitid).addEventListener("onmousedown",function(){event.cancelBubble=true;},false);
$(objconid).addEventListener("onmousedown",function(){event.cancelBubble=true;},false);
}
}else{
$(objconid).style.display="none";
}
}
//最大化、最小化
function $SH(id){
if($(id).style.display=='none'){
$(id).style.display='block';
}
else{
$(id).style.display='none';
}
}
//有图标的最大化最小化
function $SHimg(id,imgid){
if($(id).style.display=='none'){
$(id).style.display='block';
$(imgid).src="images/opentriangle.gif";
//$(imgid).style.background='url("images/opentriangle.gif")';
//$(imgid).style.backgroundRepeat='no-repeat';
//$(imgid).style.backgroundposition="5px";
}
else{
$(id).style.display='none';
$(imgid).src="images/triangle.gif";
//$CN(imgid,"tagtit")
//$(imgid).style.background='url("images/triangle.gif")';
//$(imgid).style.backgroundRepeat='no-repeat';
//$(imgid).style.backgroundposition="5px";
}
}
//左上
function $lu(divname){
document.getElementById(divname).style.top=(document.documentElement.scrollTop)+"px";
document.getElementById(divname).style.left=(document.documentElement.scrollLeft)+"px";
}
//右上
function $ru(divname){
document.getElementById(divname).style.top=(document.documentElement.scrollTop)+"px";
document.getElementById(divname).style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById(divname).offsetWidth)+"px";
}
//左下
function $ld(divname){
document.getElementById(divname).style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById(divname).offsetHeight)+"px";
document.getElementById(divname).style.left=(document.documentElement.scrollLeft)+"px";
}
//右下
function $rd(divname){
document.getElementById(divname).style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById(divname).offsetHeight)+"px";
document.getElementById(divname).style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById(divname).offsetWidth)+"px";
}
function $(objID) {
return document.getElementById(objID)
}
/*使用时仍要这样调用$(objid)
function $() {
return document.getElementById(arguments[0])
}
*/
function $F(objID,html){
$(objID).innerHTML=html;
}
function $FJ(objID,html){
$(objID).innerHTML+=html;
}
//改变样式名称
function $CN(objID,objClassName){
$(objID).className=objClassName;
}
//改变样式objstyle="none"是为不显示 objstyle="block"时为显示
function $CS(objID,objStyle)
{
$(objID).style.display=objStyle;
}
//此脚本为像QQ上线的冒泡提示调用方法:popmsg("消息内容")==================================================
var PopWidth=150; //信息框宽度
var PopHeight=80; //信息框高度
var PopBorder=25; //距屏幕边缘的距离
var PopShow=2000; //信息框的显示时间
var PopTop=0;
var showtime,hidetime;
var oPopup=window.createPopup();
function popmsg(msgstr){
oPopup.document.body.innerHTML='<table style="border:#84B9F4 solid 1px" width="'+PopWidth+
'"height="'+PopHeight+'" cellpadding="0" cellspacing="0" bgcolor="#CFEEFA">'+'<tr><td valign="top">' +msgstr+'</td></tr></table>'; //信息框的样式
popshow();
oPopup.document.body.onclick = pophide; //单击信息框时开始隐藏
}
function popshow(){
//信息框显示程序
var tmpHeight=PopTop<PopHeight?PopTop:PopHeight;//当不足以显示信息框全部时,缩小信息框高度
oPopup.show(screen.width - (PopWidth + PopBorder),screen.height-PopTop,PopWidth,tmpHeight);
//信息框定位,screen.width:屏幕宽度、screen.height:屏幕高度
if (PopTop < (PopHeight + PopBorder)){
PopTop = PopTop + 10; //信息框位置递增
}
else
{
setTimeout("pophide();", PopShow); //准备隐藏信息框
}
showtime = setTimeout("popshow();",100);
}
function pophide(){
//信息框隐藏程序
if (showtime) {
clearTimeout(showtime); //清除显示时间句柄
}
var tmpHeight=PopTop<PopHeight?PopTop:PopHeight;
oPopup.show(screen.width-(PopWidth+PopBorder),screen.height-PopTop,PopWidth,
tmpHeight);
if (PopTop>0){
PopTop=PopTop-10;
hidetime=setTimeout("pophide();",100);
}
else
{
clearTimeout(hidetime);
oPopup.hide(); //完全隐藏信息框
}
}
//========================冒泡提示结束
//日期函数
<!--
var bsYear;
var bsDate;
var bsWeek;
var arrLen=8; //数组长度
var sValue=0; //当年的秒数
var dayiy=0; //当年第几天
var miy=0; //月份的下标
var iyear=0; //年份标记
var dayim=0; //当月第几天
var spd=86400; //每天的秒数
var year1999="30;29;29;30;29;29;30;29;30;30;30;29"; //354
var year2000="30;30;29;29;30;29;29;30;29;30;30;29"; //354
var year2001="30;30;29;30;29;30;29;29;30;29;30;29;30"; //384
var year2002="30;30;29;30;29;30;29;29;30;29;30;29"; //354
var year2003="30;30;29;30;30;29;30;29;29;30;29;30"; //355
var year2004="29;30;29;30;30;29;30;29;30;29;30;29;30"; //384
var year2005="29;30;29;30;29;30;30;29;30;29;30;29"; //354
var year2006="30;29;30;29;30;30;29;29;30;30;29;29;30";
var month1999="正月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2001="正月;二月;三月;四月;闰四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2004="正月;二月;闰二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2006="正月;二月;三月;四月;五月;六月;七月;闰七月;八月;九月;十月;十一月;十二月"
var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";
var Ys=new Array(arrLen);
Ys[0]=919094400;Ys[1]=949680000;Ys[2]=980265600;
Ys[3]=1013443200;Ys[4]=1044028800;Ys[5]=1074700800;
Ys[6]=1107878400;Ys[7]=1138464000;
var Yn=new Array(arrLen); //农历年的名称
Yn[0]="己卯年";Yn[1]="庚辰年";Yn[2]="辛巳年";
Yn[3]="壬午年";Yn[4]="癸未年";Yn[5]="甲申年";
Yn[6]="乙酉年";Yn[7]="丙戌年";
var D=new Date();
var yy=D.getYear();
var mm=D.getMonth()+1;
var dd=D.getDate();
var ww=D.getDay();
if (ww==0) ww="<font color=RED>星期日";
if (ww==1) ww="星期一";
if (ww==2) ww="星期二";
if (ww==3) ww="星期三";
if (ww==4) ww="星期四";
if (ww==5) ww="星期五";
if (ww==6) ww="<font color=RED>星期六";
ww=ww;
var ss=parseInt(D.getTime() / 1000);
if (yy<100) yy="19"+yy;
for (i=0;i<arrLen;i++)
if (ss>=Ys[i]){
iyear=i;
sValue=ss-Ys[i]; //当年的秒数
}
dayiy=parseInt(sValue/spd)+1; //当年的天数
var dpm=year1999;
if (iyear==1) dpm=year2000;
if (iyear==2) dpm=year2001;
if (iyear==3) dpm=year2002;
if (iyear==4) dpm=year2003;
if (iyear==5) dpm=year2004;
if (iyear==6) dpm=year2005;
if (iyear==7) dpm=year2006;
dpm=dpm.split(";");
var Mn=month1999;
if (iyear==2) Mn=month2001;
if (iyear==5) Mn=month2004;
if (iyear==7) Mn=month2006;
Mn=Mn.split(";");
var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";
Dn=Dn.split(";");
dayim=dayiy;
var total=new Array(13);
total[0]=parseInt(dpm[0]);
for (i=1;i<dpm.length-1;i++) total[i]=parseInt(dpm[i])+total[i-1];
for (i=dpm.length-1;i>0;i--)
if (dayim>total[i-1]){
dayim=dayim-total[i-1];
miy=i;
}
bsWeek=ww;
bsDate=yy+"年"+mm+"月";
var bsDate2=dd;
bsYear="农历";
bsYear2=Mn[miy]+Dn[dayim-1];
if (ss>=Ys[7]||ss<Ys[0]) bsYear=Yn[7];
function cal(){
document.write("<span title='"+bsYear+""+bsYear2+"'>"+bsDate+""+bsDate2+"日 ");
document.write(bsWeek+"</span>");
}
/https://img.qb5200.com/download-x/div 层的增加与减小
function ResizeDiv(obj,pm)
{
if(pm=="+")
$[obj].style.pixelHeight = $[obj].style.pixelHeight + 50;
else if(pm=="-")
$[obj].style.pixelHeight = $[obj].style.pixelHeight - 50;
}
//控制字体大小
function setFontSize(id,pt){
try{
var t=document.getElementById(id);
if(t){
t.style.fontSize=pt+"pt";
}
}catch(e){}
}
function Click(){ alert('不许动,哈哈哈哈!'); window.event.returnValue=false; } document.oncontextmenu=Click;
function $showdiv(objtitid,objconid){
if($(objconid).style.display=="none"){
$(objconid).style.display="block";
var Ka=navigator.userAgent.toLowerCase();
var rt=Ka.indexOf("opera")!=-1;
var r=Ka.indexOf("msie")!=-1&&(document.all&&!rt);
if(r){
document.attachEvent("onmousedown",function (){$(objconid).style.display="none";document.onmousedown = null; } );
$(objtitid).attachEvent("onmousedown",function(){event.cancelBubble=true;});
$(objconid).attachEvent("onmousedown",function(){event.cancelBubble=true;});
} else {
document.addEventListener("onmousedown",function (){$(objconid).style.display="none";document.onmousedown = null; },false);
$(objtitid).addEventListener("onmousedown",function(){event.cancelBubble=true;},false);
$(objconid).addEventListener("onmousedown",function(){event.cancelBubble=true;},false);
}
}else{
$(objconid).style.display="none";
}
}
//最大化、最小化
function $SH(id){
if($(id).style.display=='none'){
$(id).style.display='block';
}
else{
$(id).style.display='none';
}
}
//有图标的最大化最小化
function $SHimg(id,imgid){
if($(id).style.display=='none'){
$(id).style.display='block';
$(imgid).src="images/opentriangle.gif";
//$(imgid).style.background='url("images/opentriangle.gif")';
//$(imgid).style.backgroundRepeat='no-repeat';
//$(imgid).style.backgroundposition="5px";
}
else{
$(id).style.display='none';
$(imgid).src="images/triangle.gif";
//$CN(imgid,"tagtit")
//$(imgid).style.background='url("images/triangle.gif")';
//$(imgid).style.backgroundRepeat='no-repeat';
//$(imgid).style.backgroundposition="5px";
}
}
//左上
function $lu(divname){
document.getElementById(divname).style.top=(document.documentElement.scrollTop)+"px";
document.getElementById(divname).style.left=(document.documentElement.scrollLeft)+"px";
}
//右上
function $ru(divname){
document.getElementById(divname).style.top=(document.documentElement.scrollTop)+"px";
document.getElementById(divname).style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById(divname).offsetWidth)+"px";
}
//左下
function $ld(divname){
document.getElementById(divname).style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById(divname).offsetHeight)+"px";
document.getElementById(divname).style.left=(document.documentElement.scrollLeft)+"px";
}
//右下
function $rd(divname){
document.getElementById(divname).style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById(divname).offsetHeight)+"px";
document.getElementById(divname).style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById(divname).offsetWidth)+"px";
}
function $(objID) {
return document.getElementById(objID)
}
/*使用时仍要这样调用$(objid)
function $() {
return document.getElementById(arguments[0])
}
*/
function $F(objID,html){
$(objID).innerHTML=html;
}
function $FJ(objID,html){
$(objID).innerHTML+=html;
}
//改变样式名称
function $CN(objID,objClassName){
$(objID).className=objClassName;
}
//改变样式objstyle="none"是为不显示 objstyle="block"时为显示
function $CS(objID,objStyle)
{
$(objID).style.display=objStyle;
}
//此脚本为像QQ上线的冒泡提示调用方法:popmsg("消息内容")==================================================
var PopWidth=150; //信息框宽度
var PopHeight=80; //信息框高度
var PopBorder=25; //距屏幕边缘的距离
var PopShow=2000; //信息框的显示时间
var PopTop=0;
var showtime,hidetime;
var oPopup=window.createPopup();
function popmsg(msgstr){
oPopup.document.body.innerHTML='<table style="border:#84B9F4 solid 1px" width="'+PopWidth+
'"height="'+PopHeight+'" cellpadding="0" cellspacing="0" bgcolor="#CFEEFA">'+'<tr><td valign="top">' +msgstr+'</td></tr></table>'; //信息框的样式
popshow();
oPopup.document.body.onclick = pophide; //单击信息框时开始隐藏
}
function popshow(){
//信息框显示程序
var tmpHeight=PopTop<PopHeight?PopTop:PopHeight;//当不足以显示信息框全部时,缩小信息框高度
oPopup.show(screen.width - (PopWidth + PopBorder),screen.height-PopTop,PopWidth,tmpHeight);
//信息框定位,screen.width:屏幕宽度、screen.height:屏幕高度
if (PopTop < (PopHeight + PopBorder)){
PopTop = PopTop + 10; //信息框位置递增
}
else
{
setTimeout("pophide();", PopShow); //准备隐藏信息框
}
showtime = setTimeout("popshow();",100);
}
function pophide(){
//信息框隐藏程序
if (showtime) {
clearTimeout(showtime); //清除显示时间句柄
}
var tmpHeight=PopTop<PopHeight?PopTop:PopHeight;
oPopup.show(screen.width-(PopWidth+PopBorder),screen.height-PopTop,PopWidth,
tmpHeight);
if (PopTop>0){
PopTop=PopTop-10;
hidetime=setTimeout("pophide();",100);
}
else
{
clearTimeout(hidetime);
oPopup.hide(); //完全隐藏信息框
}
}
//========================冒泡提示结束
//日期函数
<!--
var bsYear;
var bsDate;
var bsWeek;
var arrLen=8; //数组长度
var sValue=0; //当年的秒数
var dayiy=0; //当年第几天
var miy=0; //月份的下标
var iyear=0; //年份标记
var dayim=0; //当月第几天
var spd=86400; //每天的秒数
var year1999="30;29;29;30;29;29;30;29;30;30;30;29"; //354
var year2000="30;30;29;29;30;29;29;30;29;30;30;29"; //354
var year2001="30;30;29;30;29;30;29;29;30;29;30;29;30"; //384
var year2002="30;30;29;30;29;30;29;29;30;29;30;29"; //354
var year2003="30;30;29;30;30;29;30;29;29;30;29;30"; //355
var year2004="29;30;29;30;30;29;30;29;30;29;30;29;30"; //384
var year2005="29;30;29;30;29;30;30;29;30;29;30;29"; //354
var year2006="30;29;30;29;30;30;29;29;30;30;29;29;30";
var month1999="正月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2001="正月;二月;三月;四月;闰四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2004="正月;二月;闰二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2006="正月;二月;三月;四月;五月;六月;七月;闰七月;八月;九月;十月;十一月;十二月"
var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";
var Ys=new Array(arrLen);
Ys[0]=919094400;Ys[1]=949680000;Ys[2]=980265600;
Ys[3]=1013443200;Ys[4]=1044028800;Ys[5]=1074700800;
Ys[6]=1107878400;Ys[7]=1138464000;
var Yn=new Array(arrLen); //农历年的名称
Yn[0]="己卯年";Yn[1]="庚辰年";Yn[2]="辛巳年";
Yn[3]="壬午年";Yn[4]="癸未年";Yn[5]="甲申年";
Yn[6]="乙酉年";Yn[7]="丙戌年";
var D=new Date();
var yy=D.getYear();
var mm=D.getMonth()+1;
var dd=D.getDate();
var ww=D.getDay();
if (ww==0) ww="<font color=RED>星期日";
if (ww==1) ww="星期一";
if (ww==2) ww="星期二";
if (ww==3) ww="星期三";
if (ww==4) ww="星期四";
if (ww==5) ww="星期五";
if (ww==6) ww="<font color=RED>星期六";
ww=ww;
var ss=parseInt(D.getTime() / 1000);
if (yy<100) yy="19"+yy;
for (i=0;i<arrLen;i++)
if (ss>=Ys[i]){
iyear=i;
sValue=ss-Ys[i]; //当年的秒数
}
dayiy=parseInt(sValue/spd)+1; //当年的天数
var dpm=year1999;
if (iyear==1) dpm=year2000;
if (iyear==2) dpm=year2001;
if (iyear==3) dpm=year2002;
if (iyear==4) dpm=year2003;
if (iyear==5) dpm=year2004;
if (iyear==6) dpm=year2005;
if (iyear==7) dpm=year2006;
dpm=dpm.split(";");
var Mn=month1999;
if (iyear==2) Mn=month2001;
if (iyear==5) Mn=month2004;
if (iyear==7) Mn=month2006;
Mn=Mn.split(";");
var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";
Dn=Dn.split(";");
dayim=dayiy;
var total=new Array(13);
total[0]=parseInt(dpm[0]);
for (i=1;i<dpm.length-1;i++) total[i]=parseInt(dpm[i])+total[i-1];
for (i=dpm.length-1;i>0;i--)
if (dayim>total[i-1]){
dayim=dayim-total[i-1];
miy=i;
}
bsWeek=ww;
bsDate=yy+"年"+mm+"月";
var bsDate2=dd;
bsYear="农历";
bsYear2=Mn[miy]+Dn[dayim-1];
if (ss>=Ys[7]||ss<Ys[0]) bsYear=Yn[7];
function cal(){
document.write("<span title='"+bsYear+""+bsYear2+"'>"+bsDate+""+bsDate2+"日 ");
document.write(bsWeek+"</span>");
}
/https://img.qb5200.com/download-x/div 层的增加与减小
function ResizeDiv(obj,pm)
{
if(pm=="+")
$[obj].style.pixelHeight = $[obj].style.pixelHeight + 50;
else if(pm=="-")
$[obj].style.pixelHeight = $[obj].style.pixelHeight - 50;
}
//控制字体大小
function setFontSize(id,pt){
try{
var t=document.getElementById(id);
if(t){
t.style.fontSize=pt+"pt";
}
}catch(e){}
}
drag.js主要用于移动
复制代码 代码如下:
var x0=0,y0=0,x1=0,y1=0;
var offx=6,offy=6;
var moveable=false;
var normal='#C6E7FF'; //正常时的背景颜色
var index=10000; //z-index;
//开始拖动;
function startDrag(obj)
{
if(event.button==1)
{
obj.setCapture(); //锁定标题栏;
var win = obj.parentNode; //定义对象;
x0 = event.clientX; //记录鼠标和层位置;
y0 = event.clientY;
x1 = parseInt(win.style.left);
y1 = parseInt(win.style.top);
moveable = true;
}
}
//拖动;
function drag(obj)
{
if(moveable)
{
var win = obj.parentNode;
win.style.left = x1 + event.clientX - x0;
win.style.top = y1 + event.clientY - y0;
}
}
//停止拖动;
function stopDrag(obj)
{
if(moveable)
{
obj.releaseCapture();
moveable = false;
}
}
//获得焦点;
function getFocus(obj)
{
if(obj.style.zIndex!=index)
{
index = index + 2;
var idx = index;
obj.style.zIndex=idx;
obj.nextSibling.style.zIndex=idx-1;
}
}
//最小化;
function min(obj)
{
var win=obj.parentNode.parentNode.parentNode;
var msg=win.childNodes;
var flg=msg(1).style.display;
if(flg=="none")
{
msg(1).style.display = "block";
obj.src= "images/opentriangle.gif";
}else{
msg(1).style.display = "none";
obj.src= "images/TRIANGLE.GIF";
}
}
//创建一个对象;
function xWin(id,w,h,l,t,tit,msg)
{
index = index+2;
this.id = id;
this.width = w;
this.height = h;
this.left = l;
this.top = t;
this.zIndex = index;
this.title = tit;
this.message = msg;
this.obj = null;
this.bulid = bulid;
this.bulid();
}
//初始化;
function bulid()
{
var str = ""
+ "<div id=xMsg" + this.id + " "
+ "style='"
+ "z-index:" + this.zIndex + ";"
+ "width:" + this.width + ";"
+ "left:" + this.left + ";"
+ "top:" + this.top + ";"
+ "background-color:#fff;"
+ "color:#000;"
+ "font-size:14px;"
+ "position:absolute;"
+ "display:none;"
+ "border:#6BC3FF 1px solid ;'"
+ "onmousedown='getFocus(this)'>"
+ "<div "
+ "style='"
+ "background-color:" + normal + ";"
+ "width:" + (this.width+5) + ";"
+ "line-height:26px;cursor:move;border:1px #ccc solid;"
+ "margin:1px;vertical-align:middle"
+ "' "
+ "onmousedown='startDrag(this)' "
+ "onmouseup='stopDrag(this)' "
+ "onmousemove='drag(this)' "
+ "ondblclick='min(this.childNodes[1])'"
+ ">"
+ "<span style='float:left;width:50%;text-align:left;padding-left:3px;font-weight:bold;'>" + this.title +""+"</span>"
+ "<span style='float:right;width:47%;text-align:right;padding-right:3px;padding-top:5px;'> "
+"<img src='images/opentriangle.GIF' onclick='min(this)' style='cursor:pointer;'/> "
+"<img src='images/CloseBtn.gif' onclick='$SHwin(\""+this.id+"\")' style='cursor:pointer;'/></span>"
+ "</div>"
+ "<div style='"
+ "width:100%;"
+ "height:" + this.height + ";"
+ "background-color:white;"
+ "line-height:14px;"
+ "word-break:break-all;"
+ "padding:3px;"
+ "'>" + this.message + "</div>"
+ "</div>"
document.body.insertAdjacentHTML("beforeEnd",str);
}
function $SHwin(id){
if(document.getElementById("xMsg"+id).style.display=='none'){
document.getElementById("xMsg"+id).style.display='block';
}
else{
document.getElementById("xMsg"+id).style.display='none';
}
}
加载全部内容