JavaScript对文本框内容进行打印、另存为、运行及复制的代码
2012-03-09 19:48
441 查看
<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>
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>
相关文章推荐
- JavaScript打印iframe内容示例代码
- 复制所有属性进行继承 转自 博客园 汤姆大叔 深入理解JavaScript系列(46):代码复用模式(推荐篇)
- 文本编辑器: 运行代码,复制到剪贴板,另存为
- 点击复制文本框内容的代码
- JS 运行、复制、另存为 代码。
- 使用javascript对网页的部分内容进行打印
- 校验HTML文本框中输入的内容全部为数字的javascript代码
- 面试题之请写出用于校验 HTML 文本框中输入的内容全部为数字 的 javascript 代码
- 打开,另存为,属性以及将内容复制到剪贴板等JS代码
- 「JavaScript」梅花雪日历控件3.0-直接复制代码保存为html格式即可运行
- 用javascript 复制文本框中的内容到剪切板
- 请写出用于校验HTML文本框中输入的内容全部为数字的javascript代码
- 将文本框的内容复制到剪贴板(javascript)
- 点击运行、复制、另存为功能代码[带运行,复制,另存为]
- JavaScript自动复制文本框的内容到另一个文本框中
- 网站内容禁止复制和粘贴、另存为的js代码
- 禁止网站页面内容被复制的javascript代码,在公共js文件中写入下图中代码(兼容forefox和IE)
- javascript禁止访客复制网页内容的实现代码
- 复制文本框里内容的js代码
- JavaScript实现复制内容到粘贴板代码