<script>
 /*工厂模式是用于当很多对象都要调用一个对象里的各种共同方法时*/
 var page = page || {};
 page.dom = page.dom || {};
 //子函数1:处理文本
 page.dom.Text = function () { 
    this.insert = function (where) {  
	var txt = document.createTextNode(this.url);
	where.appendChild(txt);
	};
 };
 //子函数2:处理链接
 page.dom.Link = function () {
   this.insert = function (where) { 
   var link = document.createElement('a');
   link.href = this.url;        
   link.appendChild(document.createTextNode(this.url));        
   where.appendChild(link);   
    };
 };
 //子函数3:处理图片
 page.dom.Image = function () {
    this.insert = function (where) {   
	var im = document.createElement('img');        
	im.src = this.url;        
	where.appendChild(im);    
	};
 };
 
 page.dom.factory = function (type) { return new page.dom[type]; }
</script>
<script>
 var o = page.dom.factory('Link');
 o.url = 'http://;
 o.insert(document.body);
</script>