当前位置:首页 » 好文分享 » 详情

    代码在线操作代码分享

     我们在写博文时需要添加一段代码,为让读者能即时看到代码效果,我们需加上其他代码可以有运行代码,复制代码,另存代码的效果。

    演示:

    <div>欢迎订阅李明博客:<a href="https://www.blogs.hk" kesrc="https://www.blogs.hk">https://www.blogs.hk</a></div>


     

    代码在线操作代码:


     <p class="MsoNormal"><textarea style="width:679px;height:94px;" cols="50" rows="15" name="code" class="c-sharp">
    <style>
        .button { border:1px solid #b1b4cd; background:#696d81; color:#ffffff; height:25px; line-height:25px; }
    </style>
    <script language="javascript">
    function runCode(obj){
        var bb=window.open('', "_blank", '');
        bb.document.open('text/html', 'replace');
        bb.opener = null; // 防止代码对页面修改
        var obj=document.getElementById(obj);
        bb.document.write(obj.value);
        bb.document.close();
    }
    function copycode(obj) {
        var obj=document.getElementById(obj);
        obj.select();
        document.execCommand("copy");
    }
    function saveCode(obj) {
        var obj=document.getElementById(obj);
        document.write(obj.value);
        document.close();
        document.execCommand("saveAs",0,"nuodou_com_test.htm");
    }
    </script>
    <textarea id="code" cols=80 rows=15>加上你的代码</textarea>
    <br /><br />
    <input type="button" onclick='javascript:runCode("code")' value="运行代码" class="button">
    <input type="button" onclick='javascript:copycode("code")' value="复制代码" class="button">
    <input type="button" onclick='javascript:saveCode("code")' value="另存代码" class="button">
    <br /><br />
    </textarea>&nbsp;</p>



    打赏
    X
    打赏方式:
    • 支付宝
    • 微信
    • QQ红包

    打开支付宝扫一扫
    日期:2013年01月17日 02:01:13 星期三   分类:好文分享   浏览(57226)   评论(12)
    本文地址:https://www.blogs.hk/post-80.html   [百度已收录]
    声明:本页信息由网友自行发布或来源于网络,真实性、合法性由发布人负责,请仔细甄别!本站只为传递信息,我们不做任何双方证明,也不承担任何法律责任。文章内容若侵犯你的权益,请联系本站删除!
    版权所有:《博客之家
    文章标题:《代码在线操作代码分享
    除非注明,文章均为 《博客之家》 原创
    转载请注明本文短网址:https://www.blogs.hk/post-80.html  [生成短网址]

    留言咨询

    自动获取QQ

    昵称

    邮箱

    网址

    5楼、站长谈 [回复该留言]
    2013-06-19 11:53
    以后多多关注,寻求个链接呗。
    4楼、bluesky [回复该留言]
    2013-01-20 22:13
    哈哈,试了一下~
    李明 [回复该留言]
    2013-01-21 13:08
    @bluesky:试后怎样,哈哈!
    bluesky [回复该留言]
    2013-01-21 15:59
    @李明:没细试,现在宕机了,再等等,呵呵~
    李明 [回复该留言]
    2013-01-21 16:31
    @bluesky:你一定很忙吧.
    bluesky [回复该留言]
    2013-01-21 20:23
    @李明:哈哈,没有没有,话说收费主机都不能保证100%的正常,我这一个月的几分钟到几个小时的宕机很知足的,真比那些廉价的收费主机都好,就是数据库小了些。
    李明 [回复该留言]
    2013-01-21 20:42
    @bluesky:我有个500M香港收费空间,我打算搬家了,但用三蛋感觉也不差,在考虑是否搬空间。
    3楼、无名智者 [回复该留言]
    2013-01-20 20:50
    - - Chrome,Firefox等浏览器用JS的方法复制是行不通的
    李明 [回复该留言]
    2013-01-20 21:24
    @无名智者:IE是可以的。
    2楼、Google优化 [回复该留言]
    2013-01-17 16:09
    真厉害,向你学习
    1楼、室内设计博客 [回复该留言]
    2013-01-17 13:47
    只是在学习阶段。
    李明 [回复该留言]
    2013-01-17 16:15
    @室内设计博客:互相学习吧。

        站点统计

        • 收录网址:3370 个
        • 发布文章:3008 条
        • 在线人数:1人
        • 总访问量:270545832次
        • 本站运行:12年5月3天
        Copyright © 2025 博客之家 版权所有  
        關於本站免責聲明sitemap新站登錄