首页 > 网站 > WEB开发 > 正文

JS实现简单的运行代码 & 侧边广告

2024-04-27 14:21:10
字体:
来源:转载
供稿:网友

JS实现简单的运行代码 & 侧边广告

/* 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>

@黑眼诗人

/* 侧边底部广告 */<!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>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表