<!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;
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;
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="运行代码" onclick="runCode('content')">
<input type="button" name="Submit3" value="全选代码" onclick="$('content').select();">
<input type="button" name="Submit4" value="复制代码" onclick="oCopy('content')">
<input type="button" name="Submit2" value="保存代码" onclick="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>