代码操作

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

    <meta name="Author" content="JunjunChen">

    <title> 代码操作</title>

    <link rel="Shortcut Icon" href="__ROOT__/favicon.ico">

    <link rel="Bookmark" href="__ROOT__/favicon.ico">

    <meta name="keywords" content="代码操作" />

    <meta name="description" content="代码操作" />

    <script type="text/javascript" src="https://file.alonesky.com/jscss/jquery.js"></script>

    <style type="text/css">

    #softpara_main_left textarea {

        font-family: Courier New;

        width: 550px;

        height: 142px;

        font-size: 9pt;

        border: 1px solid #B5C3D3;

        padding: 10px;

        margin-bottom: 6px;

    }

    </style>

</head>

<body>

    <div id="softpara_main_left">

        <textarea name="content" id="content">

<!doctype html>

<html>

<head>

    <meta charset="UTF-8">

    <title>蓝色理了个想</title>

    <style>

    .wrap {}

    .wrap .box {

        border: 2px solid red;

        width: 200px;

        height: 200px;

        float: left;

        margin-right: 10px;

        margin-bottom: 10px;

    }

    .wrap .box:hover h1 {

        display: block;

    }

    .wrap .box h1 {

        background: #333;

        color: white;

        display: none;

     }

     </style>

</head>

<body>

    <div>

        <div>

            <h1>明天还爱我</h1>

        </div>

        <div>

            <h1>东北松花江</h1>

        </div>

        <div>

            <h1>希望的田野</h1>

        </div>

    </div>

</body>

</html>

</textarea>

    </div>

    <input type="button" name="Submit" value="运行代码" οnclick="runCode('content')">

    <input type="button" name="Submit3" value="全选代码" οnclick="$('content').select();">

    <input type="button" name="Submit4" value="复制代码" οnclick="oCopy('content')">

    <input type="button" name="Submit2" value="保存代码" οnclick="saveCode('content')">

</body>

<script type="text/javascript">

var Array();

var userAgent = navigator.userAgent.toLowerCase();

var is_opera = userAgent.indexOf('opera') != -1 && opera.version();

var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);

var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

Array.prototype.push = function(value) {

this[this.length] = value;

return this.length;

}

function $(objname) {

return document.getElementById(objname);

}

function runCode(objname) {

var winname = window.open('', "_blank", '');

var obj = $(objname);

winname.document.open('text/html', 'replace');

winname.opener = null; // 防止代码对论谈页面修改

winname.document.write(obj.value);

winname.document.close();

}

function saveCode(objname) {

var winname = window.open('', '_blank', 'top=10000');

winname.document.open('text/html', 'replace');

var obj = $(objname);

winname.document.write(obj.value);

winname.document.execCommand('saveas', '', 'code.htm');

winname.close();

}

function oCopy(objname) {

var obj = $(objname);

obj.select();

js = obj.createTextRange();

js.execCommand("Copy");

alert("提示:代码已经被成功复制!");

}

</script>

</html>

 

转载于:https://www.cnblogs.com/alonesky/p/9954078.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值