cnblogs csdn 代碼運(yùn)行框?qū)崿F(xiàn)代碼
更新時間:2009年11月02日 01:57:09 作者:
大家用cnblogs,csdn博客發(fā)布技術(shù)文檔的時候,可以用下面的代碼實(shí)現(xiàn)運(yùn)行功能。當(dāng)然大家看了源碼就會發(fā)現(xiàn)其實(shí)方法還有很多。有更好的方法就發(fā)布一下啊。
下面這個是cnblogs的實(shí)現(xiàn)代碼
<script type="text/javascript">
function runCode(obj) {
var winname = window.open('', "_blank", '');
winname.document.open('text/html', 'replace');
winname.document.write(obj.value);
winname.document.close();
}
</script>
<textarea style="width: 80%" id="code1" rows="10">
<script type="text/javascript">
alert("Got it!");
</script>
</textarea><br/ />
<input type="button" value="run" onclick="runCode(document.getElementById('code1'))"/>
下面這個是 csdn下實(shí)現(xiàn)代碼。
<script type="text/javascript"><!--
function viewPage(html) {
var page = window.open('', '', '');
page.opener = null;
page.document.write(html);
page.document.close();
}
// --></script>
<a href="javascript:viewPage(document.getElementsByTagName('textarea')[0].value)">運(yùn)行代碼</a></p>
<p><textarea cols="83" rows="15" name="code" class="xhtml">
<script>
alert('腳本之家');
</script>
</textarea>
復(fù)制代碼 代碼如下:
<script type="text/javascript">
function runCode(obj) {
var winname = window.open('', "_blank", '');
winname.document.open('text/html', 'replace');
winname.document.write(obj.value);
winname.document.close();
}
</script>
<textarea style="width: 80%" id="code1" rows="10">
<script type="text/javascript">
alert("Got it!");
</script>
</textarea><br/ />
<input type="button" value="run" onclick="runCode(document.getElementById('code1'))"/>
下面這個是 csdn下實(shí)現(xiàn)代碼。
復(fù)制代碼 代碼如下:
<script type="text/javascript"><!--
function viewPage(html) {
var page = window.open('', '', '');
page.opener = null;
page.document.write(html);
page.document.close();
}
// --></script>
<a href="javascript:viewPage(document.getElementsByTagName('textarea')[0].value)">運(yùn)行代碼</a></p>
<p><textarea cols="83" rows="15" name="code" class="xhtml">
<script>
alert('腳本之家');
</script>
</textarea>
相關(guān)文章
深入理解JavaScript系列(16) 閉包(Closures)
本章我們將介紹在JavaScript里大家經(jīng)常來討論的話題 —— 閉包(closure)。閉包其實(shí)大家都已經(jīng)談爛了。盡管如此,這里還是要試著從理論角度來討論下閉包,看看ECMAScript中的閉包內(nèi)部究竟是如何工作的2012-04-04
JS實(shí)現(xiàn)點(diǎn)擊復(fù)選框變更DIV顯示狀態(tài)的示例代碼
下面小編就為大家分享一篇JS實(shí)現(xiàn)點(diǎn)擊復(fù)選框變更DIV顯示狀態(tài)的示例代碼,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-12-12
js實(shí)現(xiàn)防止用戶重復(fù)點(diǎn)擊的三種方法
本文主要介紹了js實(shí)現(xiàn)防止用戶重復(fù)點(diǎn)擊的三種方法,包括通過禁用按鈕、解綁點(diǎn)擊事件和使用標(biāo)記,具有一定的參考價值,感興趣的可以了解一下2025-02-02
讓回調(diào)函數(shù) showResponse 也帶上參數(shù)的代碼
讓回調(diào)函數(shù) showResponse 也帶上參數(shù)的代碼...2007-08-08
使用Browserify來實(shí)現(xiàn)CommonJS的瀏覽器加載方法
下面小編就為大家?guī)硪黄褂肂rowserify來實(shí)現(xiàn)CommonJS的瀏覽器加載方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-05-05

