js實現(xiàn)運行代碼需要刷新的解決方法
更新時間:2007年08月18日 22:42:12 作者:
現(xiàn)在大多網(wǎng)站都有“運行代碼”的功能,搜索吧也很早就實現(xiàn)了這個功能,但最近在做一個項目時,發(fā)現(xià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();
相關文章
解決window.history.back()返回上一頁有時候需要點擊多次問題
這篇文章主要介紹了解決window.history.back()返回上一頁有時候需要點擊多次問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-03-03
《JavaScript高級程序設計》閱讀筆記(一) ECMAScript基礎
ECMAScript基礎,主要包括語法,變量,關鍵字,保留字,原始值和引用值等2012-02-02
Echarts動態(tài)加載多條折線圖的實現(xiàn)代碼
這篇文章主要介紹了Echarts動態(tài)加載多條折線圖的實現(xiàn)代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-05-05
超越Jquery_01_isPlainObject分析與重構
isPlainObject是Jquery1.4后提供的新方法,用于判斷對象是否是純粹的對象(通過 {} 或者 new Object 創(chuàng)建的)。2010-10-10

