标签:body and back var star 粘贴 size cape rip
1. 禁止复制(copy),禁用鼠标右键!
<SCRIPT>
//加入页面保护
function rf()
{return false; }
document.oncontextmenu = rf
function keydown()
{if(event.ctrlKey ==true || event.keyCode ==93 || event.shiftKey ==true){return false;} }
document.onkeydown =keydown
function drag()
{return false;}
document.ondragstart=drag
function stopmouse(e) {
if (navigator.appName == ‘Netscape‘ && (e.which == 3 || e.which == 2))
return false;
else if
(navigator.appName == ‘Microsoft Internet Explorer‘ && (event.button == 2 || event.button == 3)) {
alert("版权没有,但别复制 :)");
return false;
}
return true;
}
document.onmousedown=stopmouse;
if (document.layers)
window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=stopmouse;
</SCRIPT>
<script language="javascript">
function JM_cc(ob){
var obj=MM_findObj(ob); if (obj) {
obj.select();js=obj.createTextRange();js.execCommand("Copy");}
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
</script>
2. JS和HTML互转 ~~~~~~~~~
<body>
<style>
body{font-size:9pt}
textarea {color="#707888";font-family:"verdana"}
.inputs {color="#707888";border:1px solid;background:#f4f4f4}
</style>
在这里输入你需要转换的格式,可以是JavaScript也可以是DHtml.
<br>
<textarea id="codes" >
</textarea>
<br>
<button class="inputs">
清除输出
</button>
<button class="inputs">
全选代码
</button>
<button class="inputs">
拷贝代码
</button>
<button class="inputs">
粘贴代码
</button>
<button class="inputs">
Js转Html
</button>
<button class="inputs">
Html转Js
</button>
<button class="inputs">
点击显示源文件
</button>
<button class="inputs">
预览代码[F12]
</button>
<br>
这个是输出格式的窗口:
<br>
<textarea id="outputs" ></textarea>
<br>
一个不好的消息:这个Js转Html部分现在只是支持由这个程序生成的
<br>
作者:FlashSoft2000 QQ:14433548
<input id="hide" style=‘display:none‘>
<script>
//定义title
document.title="多功能网页转换"
//显示网页源文件
function writes()
{
outputs.value=document.body.outerHTML;
}
//清除输出窗口
function clears()
{
outputs.innerHTML=‘‘;
}
//替换特定字符
//n1字符串,n2要替换的字,n3替换的字
function commute(n1,n2,n3)
{
var a1,a2,a3=0,a0=‘‘
a1=n1.length;
a2=n2.length;
for(x=0;x<=(a1-a2);x++)
{
if(n1.substr(x,a2)==n2)
{
a0+=n1.substring(a3,x);
a0+=n3;
x+=(a2-1);
a3=x+1;
}
}
if(a3<a1)a0+=n1.substring(a3,a1)
{
return a0;
}
}
//转换JavaScript为DHtml
function js2html()
{
hide.value=codes.value
hide.value=commute(hide.value,‘"""‘,‘"‘);
hide.value=commute(hide.value,‘document.write("‘,‘‘);
hide.value=commute(hide.value,‘")‘,‘‘);
hide.value=commute(hide.value,‘<script>‘,‘‘);
hide.value=commute(hide.value,‘<"/script>‘,‘‘);
outputs.value=hide.value
}
//转换DHtml为JavaScript
function html2js()
{
hide.value=codes.value
hide.value=commute(hide.value,‘"‘,‘"""‘);
hide.value=commute(hide.value,‘""‘,‘""""‘);
hide.value=commute(hide.value,‘<"/script>‘,‘<""/script>‘);
outputs.value="<script>document.write("""+hide.value+""")<"/script>"
}
//预览代码
function seeHtm()
{
open().document.write("<title>测试代码窗口</title>"+outputs.value);
}
//用快捷键F12预览
document.onkeydown=seeHtms
function seeHtms()
{
if((event.keyCode==123))
{
open().document.write("<title>测试代码窗口</title>"+outputs.value);
}
}
//全选代码
function ta()
{
outputs.select()
}
//拷贝代码
function tc()
{
document.execCommand("Copy")
}
//粘贴代码
function tp()
{
outputs.focus()
document.execCommand("Paste")
}
</script>
出处至:http://xiaobingandxiaoer.iteye.com/blog/1917696
标签:body and back var star 粘贴 size cape rip
原文地址:http://www.cnblogs.com/bcphp/p/7080330.html