tw-sack.js 字串4
/* Simple AJAX Code-Kit (SACK) */
/* 2005 Gregory Wild-Smith */
/* [url]www.twilightuniverse.com[/url] */
/* Software licenced under a modified X11 licence, see documentation or authors website for more details */
function sack(file){
this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
this.requestFile = file; // 提交的页面
this.method = "POST";
this.URLString = "";
this.encodeURIString = true;
this.execute = false;
this.onLoading = function() { };//读取中
this.onLoaded = function() { };//已经读取
this.onInteractive = function() { };//交互中
this.onCompletion = function() { }; // 信息返回之后执行的方法
this.complete = function(){};//处理完毕
this.createAJAX = function() {
try {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (err) {
this.xmlhttp = null;
}
}
if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")
this.xmlhttp = new XMLHttpRequest();
if (!this.xmlhttp){
this.failed = true;
}
};
this.setVar = function(name, value){
if (this.URLString.length < 3){
this.URLString = name "=" value;
} else {
this.URLString = "&" name "=" value;
}
}
this.encVar = function(name, value){
var varString = encodeURIComponent(name) "=" encodeURIComponent(value);
return varString;
}
this.encodeURLString = function(string){
varArray = string.split('&');
for (i = 0; i < varArray.length; i ){
urlVars = varArray[i].split('=');
if (urlVars[0].indexOf('amp;') != -1){
urlVars[0] = urlVars[0].substring(4);
}
varArray[i] = this.encVar(urlVars[0],urlVars[1]);
}
return varArray.join('&');
}
this.runResponse = function(){ 字串6
eval(this.response);
}
this.runAJAX = function(urlstring){
this.responseStatus = new Array(2);
if(this.failed && this.AjaxFailedAlert){
alert(this.AjaxFailedAlert);
} else {
if (urlstring){
if (this.URLString.length){
this.URLString = this.URLString "&" urlstring;
} else {
this.URLString = urlstring;
}
}
if (this.encodeURIString){
var timeval = new Date().getTime();
this.URLString = this.encodeURLString(this.URLString);
this.setVar("rndval", timeval);
}
if (this.element) { this.elementObj = document.getElementById(this.element); }
if (this.xmlhttp) {
var self = this;
if (this.method == "GET") {
var totalurlstring = this.requestFile "?" this.URLString;
this.xmlhttp.open(this.method, totalurlstring, true);
} else {
this.xmlhttp.open(this.method, this.requestFile, true);
}
if (this.method == "POST"){
try {
this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8') 字串3
} catch (e) {}
}
this.xmlhttp.send(this.URLString);
this.xmlhttp.onreadystatechange = function() {
switch (self.xmlhttp.readyState){
case 1: //读取中
self.onLoading();
break;
case 2: //已经读取
self.onLoaded();
break;
case 3: //交互中
self.onInteractive();
break;
case 4: //处理完毕
self.response = self.xmlhttp.responseText;
self.responseXML = self.xmlhttp.responseXML;
self.responseStatus[0] = self.xmlhttp.status;
self.responseStatus[1] = self.xmlhttp.statusText;
self.onCompletion();
if(self.execute){ self.runResponse(); }
if (self.elementObj) {
var elemNodeName = self.elementObj.nodeName;
elemNodeName.toLowerCase();
if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
self.elementObj.value = self.response;
} else {
self.elementObj.innerHTML = self.response;
}
}
self.URLString = "";
self.complete();
break;
}
};
}
}
};
this.createAJAX(); 字串7
}
display.js
function overInput(a){
getId("btn").style.border = "1px solid #54ce43"
getId("content").style.border = "1px solid #54ce43"
focs()
}
function outInput(a){
getId("btn").style.border = "1px solid #AAA"
getId("content").style.border = "1px solid #AAA"
focs()
}
function overBtn(a){
a.src = "images/hover.gif"
}
function outBtn(a){
a.src = "images/rest.gif"
}
function lrover(a){
a.style.backgroundColor = "#EEE"
}
function lrout(a){
a.style.backgroundColor = "#FFF"
}
function focs(){
getName("content").focus();
}
function clean(){
getName("content").value = ""
}
var chats = new Array()
var chatStart
function addChat(strChat){
if(chats.length > 199){
chats.shift()
}
chats.push(strChat)
chatStart = chats.length
}
function preChat(){
if(chatStart && chatStart >= 1){
if(chatStart == 1){
getName("content").value = chats[0]
ajax jsp 聊天室
来源:中国开源社区
作者:sherman
时间:2007-09-18
点击:
0
最新评论共有 2 位网友发表了评论
查看所有评论
发表评论
热点关注
- 基于Ajax:实时刷新数据,
- 采用dwr ajax和struts开发
- ASP.NET AJAX入门系列(1
- Ajax技术原理简介
- 利用Ajax实现DataGrid无刷
- Struts Ajax简单实现
- AJAX jsp无刷新验证码实例
- Ajax的原理和应用【下】
- ajax中文问题彻底解决
- ajax实现检测用户名是否存
- asp ajax实现分页效果
- 用ASP.NET AJAX实现无刷新
- 《Ajax实战》高清PDF
- ajax jsp 聊天室
- ASP.NET AJAX入门系列(2
- AJAX -惊艳酷炫效果制作者
- Ajax实现分页查询
- 分析xloadtree, 用ajax实
- ASP.NET AJAX入门系列(4
- 对google个性主页的拖拽效
相关文章

