动态执行JS、HTML

打开新窗口测试HTML代码



代码如下:
    function runCode(code)
    {
		var win = window.open('','_blank','');
		win.document.open('text/html', 'replace');
		win.opener = null;
		win.document.write(code);
		win.document.close();
    }

动态执行JS代码



代码如下:

    function runJs(code)
    {
		new Function(code)();
    }

你可能感兴趣的:(html)