收集的網(wǎng)上用的ajax之chat.js文件
更新時(shí)間:2007年04月08日 00:00:00 作者:
var xmlHttp = false;
var ichatstate ;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function sendmsg(){
var msgbody = escape(document.getElementById("msgbody").value);
var sendto = escape(document.getElementById("sendto").value);
var SendData = "msgbody=" + msgbody +"&sendto=" + sendto;
xmlHttp.open("POST","../ichat/sendmsg.asp",false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function sendok(){ if (xmlHttp.readyState == 4) { } }
xmlHttp.send(SendData);
document.getElementById("msgbody").value = "";
showmsg();
}
function hot_key() {
if (window.event.keyCode==13 && window.event.ctrlKey && document.getElementById("msgbody").value != ""){sendmsg();}
}
function exitchat(){
var url = "../ichat/online.asp?action=exit&pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function intochat(){
window.ionline.location.href="../ichat/online.asp?action=intochat";
showmsg();
}
function showonline(){
var url = "../ichat/online.asp?action=showonline&pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function showmsg(){
var url = "../ichat/getmsg.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = reloadX;
xmlHttp.send(null);
}
function reloadX() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("mymsg").innerHTML = response;
document.getElementById("mymsg").scrollTop=document.getElementById("mymsg").scrollHeight;
setTimeout("showmsg();",10000);
}
}
function saveset(){
var mycolor = document.getElementById("mycolor").value;
var msgtotal = document.getElementById("msgtotal").value;
var mystate = document.getElementById("mystate").value;
var allowmsg = document.getElementById("allowmsg").value;
var closemsg;
if(document.getElementById("closemsg").checked){
closemsg = document.getElementById("closemsg").value;
}else{
closemsg = "off";
}
var SendData = "mycolor=" + mycolor + "&msgtotal=" + msgtotal + "&mystate=" + mystate + "&allowmsg=" + allowmsg + "&closemsg=" + closemsg;
xmlHttp.open("POST","../ichat/chatset.asp",false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function sendok(){ if (xmlHttp.readyState == 4) {
alert('設(shè)定已經(jīng)保存')
if(ichatstate=="open"){window.location.reload();}
} }
xmlHttp.send(SendData);
showmsg();
document.getElementById('layer_ichatset').style.display='none';
}
function openichat(){
ichatstate="open"
}
function closeichat(){
ichatstate="close"
}
function showonlineuser(){
document.getElementById('layer_online').style.display='block';
var url = "../ichat/showonline.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = reloadX2;
xmlHttp.send(null);
}
function reloadX2() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("onlineuser").innerHTML = response;
}
}
function readset(){
document.getElementById('layer_ichatset').style.display='block';
var url = "../ichat/myset.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = showset;
xmlHttp.send(null);
}
function showset() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("setplan").innerHTML = response;
}
}
function setsendto(username) {
if (username=="所有人"){
document.getElementById("sendto").value = '';
document.getElementById("talkwith").innerHTML = '所有成員';
}else{
document.getElementById("sendto").value = username;
document.getElementById("talkwith").innerHTML = username;
}
var url = "../ichat/checkuser.asp?user="+ escape(username) + "&pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = showtips;
xmlHttp.send(null);
}
function showtips() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("userstate").innerHTML = response;
}
}
function clearlog() {
if (window.confirm("您確定需要清除所有聊天記錄嗎?")==true)
{
var url = "../ichat/clearlog.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
}
var ichatwinstate
ichatwinstate="max";
function min()
{
ichatwinstate = (ichatwinstate=="max")?"min":"max"
if (ichatwinstate=="min"){
document.getElementById('mbody').style.display='none';
document.getElementById('myichat').height= parseInt(document.getElementById('ichat_title').height);
document.getElementById('myichat').style.top = document.body.clientHeight - parseInt(document.getElementById("ichat_title").style.height) + document.body.scrollTop;
}else{
document.getElementById('mbody').style.display='block';
iresize();
}
}
function closeit(){
document.getElementById('myichat').style.display='none';
}
function iresize(){
if (ichatwinstate=="min"){
document.getElementById('myichat').style.top = document.body.clientHeight - parseInt(document.getElementById("ichat_title").style.height) + document.body.scrollTop - 1;
}else{
document.getElementById('myichat').style.top = document.body.clientHeight + document.body.scrollTop - parseInt(document.getElementById("mbody").style.height) -85;
}
}
var ey=0,ex=0,lx=0,ly=0,canDrg=false,thiso=null;
var x, y,rw,rh;
function dargit(o,e) //主函數(shù)
{
thiso = o;
canDrg = true;
if(!document.all)
{
lx = e.clientX; ly = e.clientY;
}
else
{
lx = event.x; ly = event.y;
}
if(document.all) thiso.setCapture();
try{}
catch(e){}
st(o);//置前或置后
}
document.onmousemove=function(e)
{
if(!document.all){ x = e.clientX; y = e.clientY; }else{ x = event.x; y = event.y; }
if(canDrg)
{
var ofsx = x - lx;
thiso.style.left = parseInt(thiso.style.left) + ofsx;
lx = x;
var ofsy = y - ly;
thiso.style.top = parseInt(thiso.style.top) + ofsy;
ly = y;
// 狀態(tài)欄顯示數(shù)據(jù)
//window.status=thiso.style.left+"left:top"+thiso.style.top+" rh:rw"+rh+"+"+rw;
}
}
document.onmouseup=function()
{
canDrg=false;//拖拽變量設(shè)為false
try{}
catch(e){}
if(document.all && thiso != null)
{
//ie下,將清捕獲;
thiso.releaseCapture();
thiso = null;
}
}
function st(o)
{
var p = o.parentNode;
if(p.lastChild != o)
{
p.appendChild(o);
}
if(rh<=20 && rw>=160)
{
canDrg=false;
if(rw<180)
{
//設(shè)置關(guān)閉區(qū)域;//如果不需要可以注釋掉;
//alert("關(guān)閉");
p.removeChild(o)
//removeChild(this);
}
else
{
window.status=rw+"|"+rh;
if(p.firstChild == o) return;
p.insertBefore(o, p.firstChild);
}
}
}
var ichatstate ;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function sendmsg(){
var msgbody = escape(document.getElementById("msgbody").value);
var sendto = escape(document.getElementById("sendto").value);
var SendData = "msgbody=" + msgbody +"&sendto=" + sendto;
xmlHttp.open("POST","../ichat/sendmsg.asp",false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function sendok(){ if (xmlHttp.readyState == 4) { } }
xmlHttp.send(SendData);
document.getElementById("msgbody").value = "";
showmsg();
}
function hot_key() {
if (window.event.keyCode==13 && window.event.ctrlKey && document.getElementById("msgbody").value != ""){sendmsg();}
}
function exitchat(){
var url = "../ichat/online.asp?action=exit&pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function intochat(){
window.ionline.location.href="../ichat/online.asp?action=intochat";
showmsg();
}
function showonline(){
var url = "../ichat/online.asp?action=showonline&pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function showmsg(){
var url = "../ichat/getmsg.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = reloadX;
xmlHttp.send(null);
}
function reloadX() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("mymsg").innerHTML = response;
document.getElementById("mymsg").scrollTop=document.getElementById("mymsg").scrollHeight;
setTimeout("showmsg();",10000);
}
}
function saveset(){
var mycolor = document.getElementById("mycolor").value;
var msgtotal = document.getElementById("msgtotal").value;
var mystate = document.getElementById("mystate").value;
var allowmsg = document.getElementById("allowmsg").value;
var closemsg;
if(document.getElementById("closemsg").checked){
closemsg = document.getElementById("closemsg").value;
}else{
closemsg = "off";
}
var SendData = "mycolor=" + mycolor + "&msgtotal=" + msgtotal + "&mystate=" + mystate + "&allowmsg=" + allowmsg + "&closemsg=" + closemsg;
xmlHttp.open("POST","../ichat/chatset.asp",false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function sendok(){ if (xmlHttp.readyState == 4) {
alert('設(shè)定已經(jīng)保存')
if(ichatstate=="open"){window.location.reload();}
} }
xmlHttp.send(SendData);
showmsg();
document.getElementById('layer_ichatset').style.display='none';
}
function openichat(){
ichatstate="open"
}
function closeichat(){
ichatstate="close"
}
function showonlineuser(){
document.getElementById('layer_online').style.display='block';
var url = "../ichat/showonline.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = reloadX2;
xmlHttp.send(null);
}
function reloadX2() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("onlineuser").innerHTML = response;
}
}
function readset(){
document.getElementById('layer_ichatset').style.display='block';
var url = "../ichat/myset.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = showset;
xmlHttp.send(null);
}
function showset() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("setplan").innerHTML = response;
}
}
function setsendto(username) {
if (username=="所有人"){
document.getElementById("sendto").value = '';
document.getElementById("talkwith").innerHTML = '所有成員';
}else{
document.getElementById("sendto").value = username;
document.getElementById("talkwith").innerHTML = username;
}
var url = "../ichat/checkuser.asp?user="+ escape(username) + "&pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = showtips;
xmlHttp.send(null);
}
function showtips() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("userstate").innerHTML = response;
}
}
function clearlog() {
if (window.confirm("您確定需要清除所有聊天記錄嗎?")==true)
{
var url = "../ichat/clearlog.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
}
var ichatwinstate
ichatwinstate="max";
function min()
{
ichatwinstate = (ichatwinstate=="max")?"min":"max"
if (ichatwinstate=="min"){
document.getElementById('mbody').style.display='none';
document.getElementById('myichat').height= parseInt(document.getElementById('ichat_title').height);
document.getElementById('myichat').style.top = document.body.clientHeight - parseInt(document.getElementById("ichat_title").style.height) + document.body.scrollTop;
}else{
document.getElementById('mbody').style.display='block';
iresize();
}
}
function closeit(){
document.getElementById('myichat').style.display='none';
}
function iresize(){
if (ichatwinstate=="min"){
document.getElementById('myichat').style.top = document.body.clientHeight - parseInt(document.getElementById("ichat_title").style.height) + document.body.scrollTop - 1;
}else{
document.getElementById('myichat').style.top = document.body.clientHeight + document.body.scrollTop - parseInt(document.getElementById("mbody").style.height) -85;
}
}
var ey=0,ex=0,lx=0,ly=0,canDrg=false,thiso=null;
var x, y,rw,rh;
function dargit(o,e) //主函數(shù)
{
thiso = o;
canDrg = true;
if(!document.all)
{
lx = e.clientX; ly = e.clientY;
}
else
{
lx = event.x; ly = event.y;
}
if(document.all) thiso.setCapture();
try{}
catch(e){}
st(o);//置前或置后
}
document.onmousemove=function(e)
{
if(!document.all){ x = e.clientX; y = e.clientY; }else{ x = event.x; y = event.y; }
if(canDrg)
{
var ofsx = x - lx;
thiso.style.left = parseInt(thiso.style.left) + ofsx;
lx = x;
var ofsy = y - ly;
thiso.style.top = parseInt(thiso.style.top) + ofsy;
ly = y;
// 狀態(tài)欄顯示數(shù)據(jù)
//window.status=thiso.style.left+"left:top"+thiso.style.top+" rh:rw"+rh+"+"+rw;
}
}
document.onmouseup=function()
{
canDrg=false;//拖拽變量設(shè)為false
try{}
catch(e){}
if(document.all && thiso != null)
{
//ie下,將清捕獲;
thiso.releaseCapture();
thiso = null;
}
}
function st(o)
{
var p = o.parentNode;
if(p.lastChild != o)
{
p.appendChild(o);
}
if(rh<=20 && rw>=160)
{
canDrg=false;
if(rw<180)
{
//設(shè)置關(guān)閉區(qū)域;//如果不需要可以注釋掉;
//alert("關(guān)閉");
p.removeChild(o)
//removeChild(this);
}
else
{
window.status=rw+"|"+rh;
if(p.firstChild == o) return;
p.insertBefore(o, p.firstChild);
}
}
}
相關(guān)文章
uni-app返回上一個(gè)頁面并進(jìn)行頁面刷新的方法
這篇文章主要給大家介紹了關(guān)于uni-app返回上一個(gè)頁面并進(jìn)行頁面刷新的相關(guān)資料,返回上一頁面在uniapp有多種方法,文中給出了詳細(xì)的圖文示例,需要的朋友可以參考下2023-07-07JavaScript實(shí)現(xiàn)英語單詞題庫(kù)
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)英語單詞題庫(kù),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-12-12js使用正則表達(dá)式對(duì)身份證號(hào)的判斷
這篇文章主要給大家介紹了關(guān)于js使用正則表達(dá)式對(duì)身份證號(hào)的判斷的相關(guān)資料,在用戶注冊(cè)頁面有些需求要求的比較嚴(yán)格,需要對(duì)身份證驗(yàn)證是否合法,通過此功能嚴(yán)格此系統(tǒng)軟件,從而過濾到很多,需要的朋友可以參考下2023-08-08javascript實(shí)現(xiàn)導(dǎo)航欄分頁效果
這篇文章主要為大家詳細(xì)介紹了javascript實(shí)現(xiàn)導(dǎo)航欄分頁效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-06-06詳解javascript中原始數(shù)據(jù)類型Null和Undefined
這篇文章主要介紹了javascript中原始數(shù)據(jù)類型Null和Undefined的相關(guān)資料,需要的朋友可以參考下2015-12-12layui 地區(qū)三級(jí)聯(lián)動(dòng) form select 渲染的實(shí)例
今天小編就為大家分享一篇layui 地區(qū)三級(jí)聯(lián)動(dòng) form select 渲染的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-09-09BootStrap 輪播插件(carousel)支持左右手勢(shì)滑動(dòng)的方法(三種)
這篇文章主要介紹了BootStrap 輪播插件(carousel)支持左右手勢(shì)滑動(dòng)的方法(三種)的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07