您好,欢迎来到飒榕旅游知识分享网。
搜索
您的当前位置:首页js实现运行代码需要刷新的解决方法_javascript技巧

js实现运行代码需要刷新的解决方法_javascript技巧

来源:飒榕旅游知识分享网

现在大多网站都有“运行代码”的功能,搜索吧也很早就实现了这个功能,但最近在做一个项目时,发现有些需要刷新才能看到结果,自己摸索了下,其实解决方法很简单,看如下代码:

function runCode(cod1) {
cod=document.getElementById(cod1)
var code=cod.innerText;
var newwin=window.open('','','');
newwin.opener = null;
newwin.document.write(code);
newwin.location.reload();
newwin.document.close();
}
只要加上这句就可以了:

newwin.location.reload();

Copyright © 2019- sarr.cn 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务