cnblogs 運(yùn)行代碼功能?chē)L試
更新時(shí)間:2011年08月14日 15:50:24 作者:
cnblogs 運(yùn)行代碼功能?chē)L試,使用cnblogs的朋友可以參考下。
首先定義個(gè)文本域并且給個(gè)ID
<textarea id="O_txt_1" rows="8" cols="80"> <!--要運(yùn)行的代碼--> </textarea>
然后定義個(gè)按鈕
<input type="button" value="運(yùn)行代碼" onclick="runCode('O_txt_1')" />
最后當(dāng)然是要寫(xiě)函數(shù)了,代碼如下:
function runCode(id){
var obj=document.getElementById(id);
var win = window.open('', "_blank", '');
win.document.open('text/html', 'replace');
win.opener = null;
win.document.write(obj.value);
win.document.close();
}
<textarea id="O_txt_1" rows="8" cols="80"> <!--要運(yùn)行的代碼--> </textarea>
然后定義個(gè)按鈕
<input type="button" value="運(yùn)行代碼" onclick="runCode('O_txt_1')" />
最后當(dāng)然是要寫(xiě)函數(shù)了,代碼如下:
復(fù)制代碼 代碼如下:
function runCode(id){
var obj=document.getElementById(id);
var win = window.open('', "_blank", '');
win.document.open('text/html', 'replace');
win.opener = null;
win.document.write(obj.value);
win.document.close();
}
相關(guān)文章
解決git誤commit大文件導(dǎo)致不能push問(wèn)題
這篇文章主要介紹了解決git誤commit大文件導(dǎo)致不能push問(wèn)題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-07vscode檢測(cè)到#include錯(cuò)誤請(qǐng)更新includePath的解決方法
這篇文章主要介紹了vscode檢測(cè)到#include錯(cuò)誤請(qǐng)更新includePath的解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08git clone 子模塊沒(méi)下載全的問(wèn)題解決
這篇文章主要介紹了git clone 子模塊沒(méi)下載全的問(wèn)題解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08