When using it, put runcode.js in the website directory, and put the following code where you need the effect of running the code Copy the code The code is as follows: {1} div><br /><input type="button" value="Run code" style="border-left:1px solid #B1B4CD;border-right:1px solid #494D74;border-top :1px solid #B1B4CD;;border-bottom:1px solid #494D74;background:#696D81;color:#FFFFFF;" onclick="runCode(this)"> <input type="button" style="border- left:1px solid #B1B4CD;border-right:1px solid #494D74;border-top:1px solid #B1B4CD;;border-bottom:1px solid #494D74;background:#696D81;color:#FFFFFF;"value="Copy Code" onclick="copycode(this)"> <input type="button" style="border-left:1px solid #B1B4CD;border-right:1px solid #494D74;border-top:1px solid #B1B4CD; ;border-bottom:1px solid #494D74;background:#696D81;color:#FFFFFF;"value="Save Code As" onclick="saveCode(this)"> <input type="button" style="border- left:1px solid #B1B4CD;border-right:1px solid #494D74;border-top:1px solid #B1B4CD;;border-bottom:1px solid #494D74;background:#696D81;color:#FFFFFF;"value="Restore Code" onclick="preCode(this)"> Tip: You can modify part of the code first and then run</div> <br> </div> <br>. <br>runcode.js file<br><div class="codetitle"> <span><a style="CURSOR: pointer" data="10471" class="copybut" id="copybut10471" onclick="doCopy('code10471')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code10471"> <br>//Scripts runcode for BBS ver 2008-06-30, by Bound0(bound0@veryhman.com) <br>//First published at http://bbs.blueidea.com <br>//An example: http://bbs.veryhman.com/showtopic-20094.aspx <br><br>function runCode(which) { <br> var p=which.parentNode; <br> var os=p.getElementsByTagName("textarea"); <br> if(os.length==0)return; <br> var o=os[0]; <br> var winname = window.open('', "_blank", ''); <br> winname.document.open('text/html', 'replace'); <br> winname.opener = null; <br> winname.document.write(o.value); <br> winname.document.close(); <br>} <br>function saveCode(which) { <br> var p=which.parentNode; <br> var os=p.getElementsByTagName("textarea"); <br> if(os.length==0)return; <br> var o=os[0]; <br> var winname = window.open('', '_blank', 'top=10000'); <br> winname.document.open('text/html', 'replace'); <br> winname.document.write(o.value); <br> winname.document.execCommand('saveas','','code.htm'); <br> winname.close(); <br>} <br>function copycode(which) { <br> var p=which.parentNode; <br> var os=p.getElementsByTagName("textarea"); <br> if(os.length==0)return; <br> var o=os[0]; <br> var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') 5, 3); <br> if(is_ie && o.style.display != 'none') { <br> var rng = document.body.createTextRange(); <br> rng.moveToElementText(o); <br> rng.scrollIntoView(); <br> rng.select(); <br> rng.execCommand("Copy"); <br> rng.collapse(false); <br> } <br>} <br>function text(e) <br>{ <br> var t = ""; <br> e = e.childNodes || e; <br> for ( var j = 0; j < e.length; j ) <br> { <br><br> if(e[j].nodeType != 1){t =e[j].nodeValue} <br> else <br> { <br> var k=e[j].nodeName; <br> if(k=='BR'||k=='P'){t ='rn'} <br> t =text(e[j].childNodes) <br> } <br> } <br> return t; <br>} <br>function preCode(which) { <br> var p=which.parentNode; <br> var os=p.getElementsByTagName("textarea"); <br> if(os.length==0)return; <br> var o=os[0]; <br> var osv=p.getElementsByTagName("div"); <br> if(osv.length==0)return; <br> var ov=osv[0]; <br> var c='' <br> if(typeof(ov.innerText)!="undefined"){c=ov.innerText}else{c=text(ov)} <br> o.value=c <br>} <br>(function(){var s=document.getElementsByTagName("script");preCode(s[s.length-1])})()<br> </div> <br>