js實(shí)現(xiàn)運(yùn)行代碼需要刷新的解決方法
更新時(shí)間:2007年08月18日 22:42:12 作者:
現(xiàn)在大多網(wǎng)站都有“運(yùn)行代碼”的功能,搜索吧也很早就實(shí)現(xiàn)了這個(gè)功能,但最近在做一個(gè)項(xiàng)目時(shí),發(fā)現(xiàn)有些需要刷新才能看到結(jié)果,自己摸索了下,其實(shí)解決方法很簡(jiǎn)單,看如下代碼:
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();
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();
相關(guān)文章
初探j(luò)s和簡(jiǎn)單隱藏效果的實(shí)例
下面小編就為大家分享一篇初探j(luò)s和簡(jiǎn)單隱藏效果的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2017-11-11基于js實(shí)現(xiàn)微信發(fā)送好友如何分享到朋友圈、微博
微信瀏覽器內(nèi)置了javascript私有對(duì)象WeixinJSBridge,可以實(shí)現(xiàn)發(fā)送給朋友、分享到朋友圈、分享到微博等功能,本篇文章給大家介紹基于js實(shí)現(xiàn)微信發(fā)送給朋友如何分享到朋友圈、微博,感興趣的朋友一起學(xué)習(xí)吧2015-11-11firefox和IE系列的相關(guān)區(qū)別整理 以備后用
firefox和IE系列的相關(guān)區(qū)別整理,整理相對(duì)來說還可以,但對(duì)于個(gè)別細(xì)節(jié)的處理不夠完善。具體的可以參考腳本*之家以前發(fā)布的文章。2009-12-12