allusejs.js

来自「关于网上汽车销售系统的详细编程项目实战实例」· JavaScript 代码 · 共 101 行

JS
101
字号
function $(id){
	return document.getElementById(id);
}
function _(value){
	return document.getElementsByName(value)[0];
}
/*
	打开一个模式对话框
	style:打开在模式
	_url:要打开的地址
	param:要传的参数
	sFeatures:打开对话框的样式
	callback:关闭后所执行的function
*/
function openDialog(style,_url,param,sFeatures,callback){

var ret =((style==='Modal')?window.showModalDialog(_url,param,sFeatures):window.showModelessDialog(_url,param,sFeatures));
if(ret){
if(typeof(callback)=='function'){
 callback(ret);
 }
 }
}
//设置对话框的样式
function setDialog(iHeight,iWidth,iscroll,istatus)
{
var sFeatures="dialogHeight: " + iHeight + "px;";
sFeatures+="dialogWidth: " + iWidth + "px;";
sFeatures+="scroll: " + iscroll+";";
sFeatures+="status: " + istatus+";";
return sFeatures;
}



//以下代码是AJAX技术######################################
//请求一个XML数据
var REQXML = function(){};
//请求一个HTML数据
var REQHTML=function(){};
REQHTML.prototype.GetHttpRequest=REQXML.prototype.GetHttpRequest = function()
{
	if (window.XMLHttpRequest)	return new XMLHttpRequest();	// Gecko
	else if ( window.ActiveXObject )return new ActiveXObject("Microsoft.XMLHTTP") ;	// IE
}
REQHTML.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer ){

	var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
	var oXmlHttp = this.GetHttpRequest() ;
	oXmlHttp.open( "Post", urlToCall, bAsync ) ;
	if ( bAsync )
	{	oXmlHttp.onreadystatechange = function() 
		{
			if ( oXmlHttp.readyState == 4 )
			{
				
				
				if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
					asyncFunctionPointer( oXmlHttp.responseText ) ;
				else
					alert( '请求错误:' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
			}
		}
	}
	
	oXmlHttp.send( null ) ;
}

REQXML.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
{

	var oREQXml = this ;
	var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
	var oXmlHttp = this.GetHttpRequest() ;
	oXmlHttp.open( "Post", urlToCall, bAsync ) ;
	if ( bAsync )
	{	oXmlHttp.onreadystatechange = function() 
		{
			if ( oXmlHttp.readyState == 4 )
			{
				oREQXml.DOMDocument = oXmlHttp.responseXML;
				if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
					asyncFunctionPointer( oREQXml ) ;
				else
					alert( '请求错误:' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
			}
		}
	}
	
	oXmlHttp.send( null ) ;
	if ( ! bAsync )
	{
		if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
				this.DOMDocument = oXmlHttp.responseXML ;
		else
		{
			alert( '请求错误: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?