<!DOCTYPE html> 
<html>
	<head>	
	</head>
	<body>
 <script>
	function namespace(ns) {
		if(!ns || typeof ns !== "string" || !ns.length) return null;
		var steps = ns.split(".");
		var root = window;
		for ( var i = 0, len = steps.length; i < len; i++) {
			root[steps[i]] = root[steps[i]] || {};
			root = root[steps[i]];
		}
		return root;
	}
		namespace("www.com");
		www.com.say = function() {
			console.log("hello.js....");
		}
		www.com.say();

	/*
			//test code.....
			alert(window["a1"]);
			window["a1"] = {};
			var foo = (window["a1"]);
			foo["ff"] = {};
			alert(foo["ff"]);
	*/		

 </script>
		
	</body>
</html>

  

相关文章:

  • 2022-12-23
  • 2021-10-23
  • 2021-09-06
  • 2022-12-23
  • 2022-01-11
  • 2022-01-04
  • 2021-10-04
  • 2022-01-02
猜你喜欢
  • 2021-09-05
  • 2021-11-10
  • 2021-10-09
  • 2021-11-04
  • 2022-12-23
相关资源
相似解决方案