//运行文本域代码 
function Preview(obj) { 
var TestWin=window.open('','',''); //打开一个窗口并赋给变量TestWin。 
TestWin.opener = null // 防止代码对论谈页面修改 
TestWin.document.write(obj.value); //向这个打开的窗口中写入代码code，这样就实现了运行代码功能。 
TestWin.document.close(); 
} 
//复制文本域代码 
function copyCode(obj) { 
var rng = document.body.createTextRange(); 
rng.moveToElementText(obj); 
rng.scrollIntoView(); 
rng.select(); 
rng.execCommand("Copy"); 
rng.collapse(false); 
} 
//另存文本域代码 
function saveCode(obj) { 
var winname = window.open('', '_blank', 'top=10000'); 
winname.document.open('text/html', 'replace'); 
winname.document.writeln(obj.value); 
winname.document.execCommand('saveas','','code.htm'); 
winname.close(); 
} 
//收藏本页代码 
function addBookmark(title,url) { 
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) { 
window.external.AddFavorite(url,title); 
} else if( window.opera && window.print ) { 
return true; 
} 
}