<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > |
<html xmlns= "http://www.w3.org/1999/xhtml" > |
<head> |
<meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" /> |
<title>js转html html转js--娱乐在线,超级搜索,搜软件, 电影下载, 变态资源, 图片搜索, 小说搜索, 论坛搜索, 搜索助手, 桌面搜索, 搜索推广, 搜索优化, 搜索软件, 海量搜索,电骆,BT</title> |
<meta name= "Keywords" content= "实用查询" /> |
<meta name= "GENERATOR" content= "Microsoft FrontPage 5.0" /> |
<meta name= "ProgId" content= "FrontPage.Editor.Document" /> |
<style type= "text/css" > |
/*<![CDATA[*/ |
body{font-size:9pt} |
textarea {color= "#707888" ;font-family: "verdana" } |
.inputs {color= "#707888" ;border:1px solid;background:#f4f4f4} |
/*]]>*/ |
</style> |
<base target= "_blank" /> |
<title>测试代码窗口</title> |
<title>测试代码窗口</title> |
</head> |
<body> |
<center> |
在这里输入你需要转换的格式,可以是JavaScript也可以是DHtml.<br /> |
<textarea id= "codes" style= "WIDTH: 730px; HEIGHT: 300px" > |
</textarea><br /> |
<button class= "inputs" onclick= "clears()" >清除输出</button><button class= "inputs" onclick= "ta()" >全选代码</button><button class= "inputs" onclick= "tc()" >拷贝代码</button><button class= "inputs" onclick= "tp()" >粘贴代码</button><button class= "inputs" onclick= "js2html()" >Js转Html</button><button class= "inputs" onclick= "html2js()" >Html转Js</button><button class= "inputs" onclick= "writes()" >点击显示源文件</button><button class= "inputs" onclick= "seeHtm()" >预览代码[F12]</button><br /> |
这个是输出格式的窗口:<br /> |
<textarea id= "outputs" style= "WIDTH: 730px; HEIGHT: 300px" > |
</textarea><br /> |
<br /> |
<input id= "hide" style= "DISPLAY: none" /> <script type= "text/javascript" > |
//<![CDATA[ |
//定义title |
document.title= "js转html html转js" |
//显示网页源文件 |
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 type=" text/javascript"> |
//<![CDATA[ |
document.write(\ "" +hide.value+"\")< |
//]]> |
</script> " } //预览代码 function seeHtm() { open().document.write(" "+outputs.value); } //用快捷键F12预览 document.onkeydown=seeHtms function seeHtms() { if((event.keyCode==123)) { open().document.write(" "+outputs.value); } } //全选代码 function ta() { outputs.select() } //拷贝代码 function tc() { document.execCommand(" Copy ") } //粘贴代码 function tp() { outputs.focus() document.execCommand(" Paste") } |
</center> |
</body> |
</html> |