电脑技术学习

对textarea区的各种操作按钮,非常全

dn001
<!-- 把如下代码加入<body>区域中 -->
<script language=Jscript>
function run(obj){
if (f1.code.value==''||f1.code.value==' '){
alert("您需要运行的代码为空!");obj.focus()}
else{
var winEx = window.open("", "winEx", "width=400,height=300,resizable=yes,top=0,left=0");
winEx.document.write(f1.code.value);winEx.document.close()}}
function Jia(){
document.f1.code.rows+=parseFloat(f1.h1.value)}
function Jian(ob){
if (ob.rows>3) document.f1.code.rows-=parseInt(f1.h1.value);
else alert('已接近最小值')}
function Exec(obj,cmd){
obj.select();document.execCommand(cmd)}
function Paste(obj){
obj.focus();document.execCommand('paste')}
function Exe(cmd){
document.execCommand(cmd)}
function view(){
window.location="view-source:"+window.location.href}
</script><style>body{
color:#063;font-family:arial;font-size:12}
textarea{
border:1 solid #000;font-family:arial;font-size:12;width:100%;color:red;margin:5 0}
</style>
<form name=f1>
<input type=button value='↓' onclick=Jia(code)>
<select onchange="h1.value=this.options[this.selectedIndex].value">
<option value=1>1</option><option value=2>2</option><option value=3>3</option></select>
<input type=button value='↑' onclick=Jian(code)>
<input type=button value='拷贝' onclick=Exec(code,'Copy')>
<input type=button value='剪切' onclick=Exec(code,'Cut')>
<input type=button value='粘贴' onclick=Paste(code)>
<input type=button value='清空' onclick=Exec(code,'Delete')>
<input type=button value='查看' onClick=view()>
<input type=button value='打印' onclick=Exe('print')>
<input type=button value='另存为' onclick=Exe('SaveAs')>
<input type=button value='刷新' onclick=Exe('ReFresh')>
<input type=button value='打开' onclick=Exe('Open')>
<input value=1 name=h1 type=hidden><input name=h2 type=button>
<input type=button value=运行代码' onclick=run(code)>
<textarea name=code rows="20">Input Code ...</textarea></form>
<script>function show(){
var t=new Date();var h=t.getHours();var m=t.getMinutes();
var s=t.getSeconds();if(h<10)h="0"+h;if(m<10)m="0"+m;if(s<10)s="0"+s;
document.f1.h2.value=h+":"+m+":"+s;setTimeout("show()","1000")}show()
</script>