/* JS实现简单的运行代码功能 */
<!doctype html> <html> <head> <meta charset="utf-8" /> <script> window.onload = function() { var oTxt = document.getElementById('codeText'); var oBtn = document.getElementById('btn'); oBtn.onclick = function() { var oNewWin = window.open('about:blank', '_blank'); //在新窗口中打开空白页(BOM) oNewWin.document.write(oTxt.value); //在空白页中写入输入框的值 } } </script> </head> <body> <textarea id="codeText" rows="10" cols="40"></textarea><br /> <input id="btn" type="button" value="运行" /> <!-- FF下只能关闭open打开的窗口 --> </body> </html>
Link:https://www.cnblogs.com/farwish/p/3861904.html
/* 侧边底部广告 */
<!doctype html> <html> <head> <meta charset="utf-8" /> <style> #div1 { width:200px; height:150px; background:red; position:absolute; right:0; bottom:0; } body {height:2000px;} </style> <script> window.onscroll = window.onresize = function() { //可视区尺寸 var clientW = document.documentElement.clientWidth; var clientH = document.documentElement.clientHeight; //滚动距离 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; // IE,FF || chrome //alert(scrollTop); oDiv = document.getElementById('div1'); oDiv.style.top = clientH - oDiv.offsetHeight + scrollTop + 'px';//document.navigater.userAgent判断浏览器类型,IE6使用fixed定位 } </script> </head> <body> <div id="div1"></div> </body> </html>