⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rs.htm

📁 此程序为网上下载
💻 HTM
📖 第 1 页 / 共 2 页
字号:
// ************************************************************************<BR>
// Microsoft Script Library<BR>
// Visual InterDev 6.0 Remote Scripting utilities for client<BR>
// Copyright 1998 Microsoft Corporation. All Rights Reserved.<BR>
// <B>Do not modify in design view. Switch to source view.</B><BR>
// ************************************************************************<BR>
// <SCRIPT>	
	
//*****************************************************************	
// The Remote Scripting utilities for the client consist of
// three public methods and the RSCallObject definition.
// The public methods are RSEnableRemoteScripting, RSExecute
// and RSGetASPObject. The RSCallObject is returned from any
// remote scripting call and provides status and return value.
//*****************************************************************	
	
//*****************************************************************
// function RSEnableRemoteScripting()
//	This function enables the remote scripting proxy.
//*****************************************************************
function RSEnableRemoteScripting(codebase)
{
	MSRS = new _MSRS_Object();
	if (typeof(codebase) == 'undefined')
	{	// assume applet is in _ScriptLibrary directory off the webroot
		var secondSlash, path;
		codebase = '';
		if ((secondSlash = (path = window.location.pathname).indexOf('/',1)) != -1)
			codebase = path.substring(0,secondSlash);
		codebase += '/_ScriptLibrary';
	}
	document.write('<' + 'APPLET name=RSAspProxyApplet codebase=' + codebase + ' code=RSProxy.class height=0 width=0></APPLET>');	
}

//*****************************************************************
// function RSExecute(url,method,p1 ... pn,cb,ecb,context)
//	This is the function by which remote scripting calls are made.
//	The caller provides the following :
//		url		: url to the asp file containing remote script
//		method	: name of the method to be invoked
//		p1...pn	: any parameters required by the method
//		cb		: an optional callback routine for async.
//		ecb		: an optional error callback routine for async.
//		context	: an optional user context
//*****************************************************************
function RSExecute(url,method)
{
	var cb, ecb, context;
	var params = new Array;
	var pn = 0;
	var len = RSExecute.arguments.length;
	for (var i=2; i < len; i++)
		params[pn++] = RSExecute.arguments[i];
		
	return MSRS.invokeMethod(url,method,params);
}

//*****************************************************************
// function RSGetASPObject(url)
//	This function returns a server object for an ASP file
//	described by its public_description.
//*****************************************************************
function RSGetASPObject(url)
{
	var cb, ecb, context;
	var params = new Array;
	var request = MSRS.startRequest(url,'GetServerProxy',params,cb,ecb,context);
	if (request.status == MSRS_COMPLETED)
	{
		var server = request.return_value;
		if (typeof(Function) == 'function')
		{
			for (var name in server)
				server[name] = Function('return MSRS.invokeMethod(this.location,"' +  name + '",this.' + name + '.arguments);');
		}
		else
		{	// JavaScript 1.0 does not support Function  ( IE3.0 )
			for (var name in server)
				server[name] = eval('function t(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF) { return MSRS.invokeMethod(this.location,"' + name + '",this.' + name + '.arguments);} t');
		}
		server.location = url;
		return server;
	}
	alert('Failed to create ASP object for : ' + url);
	return null;
}

//*****************************************************************
// function RSCallObject(cb,ecb,context)
//
//	The RSCallObject is returned for every remote scripting
//	invocation. It contains the return value and status.
//
//		id				:	unique id of request
//		status			:	status of request, one of 
//								MSRS_COMPLETED
//								MSRS_FAIL
//								MSRS_PENDING
//								MSRS_PARTIAL
//		message			:	message associated with status
//		data			:	raw data returned from server
//		return_value	:	evaluated value returned from server
//		callback		:	user provided callback ( optional )
//		error_callback	:	user provided callback ( optional )
//		context			:	user provided context ( optional )
//
//*****************************************************************
function RSCallObject(cb,ecb,context)
{
	this.id = MSRS.nextRequestID++;
	this.status = MSRS_PENDING;
	this.message = '';
	this.data = '';
	this.return_value = '';
		
	this.callback = cb;
	this.error_callback = ecb;
	this.context = context;

	this.wait = RSCallObject_wait;
	this.cancel = RSCallObject_cancel;

	MSRS.requestList[this.id] = this;
}

//*****************************************************************
// function RSCallObject_wait()
//
//	The RSCallObject_wait method can be called from an asynchronous
//  request to wait for it to complete.  If the request has finished
//  this call returns immediately.
//
//		this = RSCallObject instance to wait for
//*****************************************************************
function RSCallObject_wait()
{
	if (this.status != MSRS_PENDING)
		return;
	while (true)
	{	// wait synchronously for response
		if (MSRS.rsapplet.waitForResponse())
		{
			if (MSRS.rsapplet.hasResponse())
			{
				var rid = MSRS.rsapplet.getRequestID();
				MSRS.handleResponse(rid);
				// DO NOT CHANGE THIS CODE
				// Solves Java to Script discrepancies between IE3 and Navigator
				var strrid = String(rid);
				if (strrid == null)
					strrid = rid;
				if (strrid == this.id)	
					break;				// this response completed			
			}
		}
		else
		{
			this.status = MSRS_FAIL;
			this.message = 'Request not handled.'
			break;
		}
	}
}

//*****************************************************************
// function RSCallObject_cancel()
//
//	The RSCallObject_cancel method can be called from an 
//	asynchronous request to cancel it.  If the request has 
//	finished this call returns immediately.
//
//		this = RSCallObject instance to cancel
//*****************************************************************
function RSCallObject_cancel()
{
	if (this.status == MSRS_PENDING)
	{
		MSRS.rsapplet.cancelRequest(this.id);
		this.status = MSRS_FAIL;
		this.message = 'Request cancelled.'
	}
}

//*** PRIVATE IMPLEMENTATION BELOW ********************************
//*** PRIVATE IMPLEMENTATION BELOW ********************************
//*** PRIVATE IMPLEMENTATION BELOW ********************************
//*****************************************************************
//
// Remote Scripting Object --  private implementation
//
//	The following code is private glue code that contains the
//	implementation of a JSObject to enable remote scripting
//	functionality on the client. This private object is utilized
//	by the public Remote Scripting methods defined above.
//
//*****************************************************************
//*****************************************************************

//*****************************************************************
// function _MSRS_Object
//
//	This is the JSObject that interacts with the RSAspProxy
//	applet to synchronously/asynchronously retrieve data via
//	an ASP file.
//*****************************************************************
//var MSRS = new _MSRS_Object();
function _MSRS_Object()
{
	MSRS_FAIL = -1;
	MSRS_COMPLETED = 0;
	MSRS_PENDING = 1;
	MSRS_PARTIAL = 2;

	this.REQUEST_MODE_COMPLETE = 0;
	this.POLLING_PERIOD = 100;

	this.pollID = 0;
	this.pollCount = 0;
	this.nextRequestID = 1;
	this.requestList = new Array;
	this.rsapplet = null;

	this.startRequest = _MSRS_startRequest;
	this.invokeMethod = _MSRS_invokeMethod;
	this.handleResponse = _MSRS_handleResponse;
	this.evaluateRequest = _MSRS_evaluateRequest;
	this.setRequestPoll = _MSRS_setRequestPoll;
	this.requestPollHandler = _MSRS_requestPollHandler;
	this.buildURL = _MSRS_buildURL;
}

//*****************************************************************
// function _MSRS_startRequest(url,method,args,cb,ecb,context)
//
//	This is key function for initiating a request for data.
//	The url to the ASP file is required. The callback, 
//	error_callback, and user context parameters are optional.
//*****************************************************************
function _MSRS_startRequest(url,method,args,cb,ecb,context)
{
	var request = new RSCallObject(cb,ecb,context);
	if (this.rsapplet == null)
	{
		if (typeof(document.RSAspProxyApplet) == 'object')
			this.rsapplet = document.RSAspProxyApplet;
		else if (typeof(document.thisForm) == 'object' && typeof(document.thisForm.RSAspProxyApplet) == 'object')
			this.rsapplet = document.thisForm.RSAspProxyApplet;

⌨️ 快捷键说明

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