TimeLord

有志者,事竟成,卧薪尝胆,百二秦关终属楚; 苦心人,天不负,破斧沉舟, 三千越甲可吞吴!

IT博客 首页 新随笔 联系 聚合 管理
  1 Posts :: 38 Stories :: 0 Comments :: 0 Trackbacks
function runCode()  //定义一个运行代码的函数,
{
    
if(1 == arguments.length)
        
try{event = arguments[0];}catch(e){}
  
var code=(event.target || event.srcElement).parentNode.childNodes[0].value;//即要运行的代码。
  var newwin=window.open('','','');  //打开一个窗口并赋给变量newwin。
  newwin.opener = null // 防止代码对论谈页面修改
  newwin.document.write(code);  //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
  newwin.document.close();
}
posted on 2007-10-08 19:13 TimeLord 阅读(549) 评论(0)  编辑 收藏 引用 所属分类: 网页设计