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

📄 hostenv_browser.js

📁 对java中如何使用Ajax技术
💻 JS
📖 第 1 页 / 共 2 页
字号:
	function dj_addNodeEvtHdlr(/*DomNode*/node, /*String*/evtName, /*Function*/fp){		// summary:		//		non-destructively adds the specified function to the node's		//		evtName handler.		// node: the DomNode to add the handler to		// evtName: should be in the form "click" for "onclick" handlers		var oldHandler = node["on"+evtName] || function(){};		node["on"+evtName] = function(){			fp.apply(node, arguments);			oldHandler.apply(node, arguments);		}		return true;	}	//	BEGIN DOMContentLoaded, from Dean Edwards (http://dean.edwards.name/weblog/2006/06/again/)	function dj_load_init(e){		// allow multiple calls, only first one will take effect		// A bug in khtml calls events callbacks for document for event which isnt supported		// for example a created contextmenu event calls DOMContentLoaded, workaround		var type = (e && e.type) ? e.type.toLowerCase() : "load";		if(arguments.callee.initialized || (type!="domcontentloaded" && type!="load")){ return; }		arguments.callee.initialized = true;		if(typeof(_timer) != 'undefined'){			clearInterval(_timer);			delete _timer;		}		var initFunc = function(){			//perform initialization			if(dojo.render.html.ie){				dojo.hostenv.makeWidgets();			}		};		if(dojo.hostenv.inFlightCount == 0){			initFunc();			dojo.hostenv.modulesLoaded();		}else{			//This else case should be xdomain loading.			//Make sure this is the first thing in the load listener array.			//Part of the dojo.addOnLoad guarantee is that when the listeners are notified,			//It means the DOM (or page) has loaded and that widgets have been parsed.			dojo.hostenv.modulesLoadedListeners.unshift(initFunc);		}	}	//	START DOMContentLoaded	// Mozilla and Opera 9 expose the event we could use	if(document.addEventListener){		if(dojo.render.html.opera || (dojo.render.html.moz && !djConfig.delayMozLoadingFix)){			document.addEventListener("DOMContentLoaded", dj_load_init, null);		}		//	mainly for Opera 8.5, won't be fired if DOMContentLoaded fired already.		//  also used for Mozilla because of trac #1640		window.addEventListener("load", dj_load_init, null);	}	// 	for Internet Explorer. readyState will not be achieved on init call, but dojo doesn't need it	//	however, we'll include it because we don't know if there are other functions added that might.	//	Note that this has changed because the build process strips all comments--including conditional	//		ones.	if(dojo.render.html.ie && dojo.render.os.win){		document.attachEvent("onreadystatechange", function(e){			if(document.readyState == "complete"){				dj_load_init();			}		});	}	if (/(WebKit|khtml)/i.test(navigator.userAgent)) { // sniff		var _timer = setInterval(function() {			if (/loaded|complete/.test(document.readyState)) {				dj_load_init(); // call the onload handler			}		}, 10);	}	//	END DOMContentLoaded	// IE WebControl hosted in an application can fire "beforeunload" and "unload"	// events when control visibility changes, causing Dojo to unload too soon. The	// following code fixes the problem	// Reference: http://support.microsoft.com/default.aspx?scid=kb;en-us;199155	if(dojo.render.html.ie){		dj_addNodeEvtHdlr(window, "beforeunload", function(){			dojo.hostenv._unloading = true;			window.setTimeout(function() {				dojo.hostenv._unloading = false;			}, 0);		});	}	dj_addNodeEvtHdlr(window, "unload", function(){		dojo.hostenv.unloaded();		if((!dojo.render.html.ie)||(dojo.render.html.ie && dojo.hostenv._unloading)){			dojo.hostenv.unloaded();		}	});	dojo.hostenv.makeWidgets = function(){		// you can put searchIds in djConfig and dojo.hostenv at the moment		// we should probably eventually move to one or the other		var sids = [];		if(djConfig.searchIds && djConfig.searchIds.length > 0) {			sids = sids.concat(djConfig.searchIds);		}		if(dojo.hostenv.searchIds && dojo.hostenv.searchIds.length > 0) {			sids = sids.concat(dojo.hostenv.searchIds);		}		if((djConfig.parseWidgets)||(sids.length > 0)){			if(dojo.evalObjPath("dojo.widget.Parse")){				// we must do this on a delay to avoid:				//	http://www.shaftek.org/blog/archives/000212.html				// (IE bug)					var parser = new dojo.xml.Parse();					if(sids.length > 0){						for(var x=0; x<sids.length; x++){							var tmpNode = document.getElementById(sids[x]);							if(!tmpNode){ continue; }							var frag = parser.parseElement(tmpNode, null, true);							dojo.widget.getParser().createComponents(frag);						}					}else if(djConfig.parseWidgets){						var frag  = parser.parseElement(dojo.body(), null, true);						dojo.widget.getParser().createComponents(frag);					}			}		}	}	dojo.addOnLoad(function(){		if(!dojo.render.html.ie) {			dojo.hostenv.makeWidgets();		}	});	try{		if(dojo.render.html.ie){			document.namespaces.add("v","urn:schemas-microsoft-com:vml");			document.createStyleSheet().addRule("v\\:*", "behavior:url(#default#VML)");		}	}catch(e){ }	// stub, over-ridden by debugging code. This will at least keep us from	// breaking when it's not included	dojo.hostenv.writeIncludes = function(){}	//TODOC:  HOW TO DOC THIS?	// @global: dj_currentDocument	// summary:	//		Current document object. 'dj_currentDocument' can be modified for temporary context shifting.	// description:	//    dojo.doc() returns dojo.currentDocument.	//		Refer to dojo.doc() rather than referring to 'window.document' to ensure your	//		code runs correctly in managed contexts.	if(!dj_undef("document", this)){		dj_currentDocument = this.document;	}	dojo.doc = function(){		// summary:		//		return the document object associated with the dojo.global()		return dj_currentDocument;	}	dojo.body = function(){		// summary:		//		return the body object associated with dojo.doc()		// Note: document.body is not defined for a strict xhtml document		return dojo.doc().body || dojo.doc().getElementsByTagName("body")[0];	}	dojo.byId = function(/*String*/id, /*DocumentElement*/doc){		// summary:		// 		similar to other library's "$" function, takes a string		// 		representing a DOM id or a DomNode and returns the		// 		corresponding DomNode. If a Node is passed, this function is a		// 		no-op. Returns a single DOM node or null, working around		// 		several browser-specific bugs to do so.		// id: DOM id or DOM Node		// doc:		//		optional, defaults to the current value of dj_currentDocument.		//		Can be used to retreive node references from other documents.		if((id)&&((typeof id == "string")||(id instanceof String))){			if(!doc){ doc = dj_currentDocument; }			var ele = doc.getElementById(id);			// workaround bug in IE and Opera 8.2 where getElementById returns wrong element			if(ele && (ele.id != id) && doc.all){				ele = null;				// get all matching elements with this id				eles = doc.all[id];				if(eles){					// if more than 1, choose first with the correct id					if(eles.length){						for(var i=0; i<eles.length; i++){							if(eles[i].id == id){								ele = eles[i];								break;							}						}					// return 1 and only element					}else{						ele = eles;					}				}			}			return ele; // DomNode		}		return id; // DomNode	}	dojo.setContext = function(/*Object*/globalObject, /*DocumentElement*/globalDocument){		// summary:		//		changes the behavior of many core Dojo functions that deal with		//		namespace and DOM lookup, changing them to work in a new global		//		context. The varibles dj_currentContext and dj_currentDocument		//		are modified as a result of calling this function.		dj_currentContext = globalObject;		dj_currentDocument = globalDocument;	};	dojo._fireCallback = function(callback, context, cbArguments){		if((context)&&((typeof callback == "string")||(callback instanceof String))){			callback=context[callback];		}		return (context ? callback.apply(context, cbArguments || [ ]) : callback());	}	dojo.withGlobal = function(/*Object*/globalObject, /*Function*/callback, /*Object?*/thisObject, /*Array?*/cbArguments){		// summary:		//		Call callback with globalObject as dojo.global() and globalObject.document		//		as dojo.doc(). If provided, globalObject will be executed in the context of		//		object thisObject		// description:		//		When callback() returns or throws an error, the dojo.global() and dojo.doc() will		//		be restored to its previous state.		var rval;		var oldGlob = dj_currentContext;		var oldDoc = dj_currentDocument;		try{			dojo.setContext(globalObject, globalObject.document);			rval = dojo._fireCallback(callback, thisObject, cbArguments);		}finally{			dojo.setContext(oldGlob, oldDoc);		}		return rval;	}	dojo.withDoc = function (/*Object*/documentObject, /*Function*/callback, /*Object?*/thisObject, /*Array?*/cbArguments) {		// summary:		//		Call callback with documentObject as dojo.doc(). If provided, callback will be executed		//		in the context of object thisObject		// description:		//		When callback() returns or throws an error, the dojo.doc() will		//		be restored to its previous state.		var rval;		var oldDoc = dj_currentDocument;		try{			dj_currentDocument = documentObject;			rval = dojo._fireCallback(callback, thisObject, cbArguments);		}finally{			dj_currentDocument = oldDoc;		}		return rval;	}} //if (typeof window != 'undefined')

⌨️ 快捷键说明

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