Js与Html互转的一个hta的小工具

最近对脚本有点感兴趣了..自己试着搞了个小东西出来..

 

< HTA:APPLICATION
 
BORDER ="dialog"
 INNERBORDER
="no"
 BORDERSTYLE
="normal"  
 CAPTION
="yes"  
 MAXIMIZEBUTTON
="no"  
 MINIMIZEBUTTON
="yes"  
 SHOWINTASKBAR
="yes"  
 SINGLEINSTANCE
="no"  
 SYSMENU
="yes"
 SCROLL
="no"   >
< head >
< meta  http-equiv =Content-Type  content ="text/html; charset=gb2312" >
< title > HTML 与 JS 代码互转 - Sea </ title >
< style >
body
{background-color:menu;margin:0;font-size:12px;}
#head
{border:1px solid #777;padding:5px 10px;margin:2px;text-align:right;}
#oper
{text-align:center;display:inline;width:80%;}
#convert
{text-align:center;margin:5px;}
#oSource
{width:460px;height:200px;}
#oResult
{width:460px;height:200px;background:menu;}
#foot
{padding:5px 10px;margin:2px 20px;text-align:right;}
</ style >
< SCRIPT  FOR ="window"  EVENT ="onload" >
initialize();
</ SCRIPT >
< script >
// Event handler for window.onload()
function initialize()   {
    initWindow();
}


// Applies initial state settings for the application
function initWindow()   {
    setWindowSize(
500540);
    window.moveTo(
100,50);
}


// Resizes the current window
function setWindowSize(width, height){
    window.resizeTo(width, height);
}


// Opens a new window
function popWindow(url, name)
{
    
// New window will be used to popup window if we haven't opened a readme before;
    // Otherwise the same window will open again, only toolbar visible, resizable 
    var wndPopup = window.open(url,name,"");
    
// Bring new window to foreground
    wndPopup.focus();
}

function doConvert()
{
  
var ConvertResult;
  
var v=oSource.value;
  
if (ConvertType1.checked) ConvertResult=html2js(v); else ConvertResult=js2html(v);
  oResult.value
=ConvertResult;
}


function html2js(paraV)
{
    
return "document.writeln(""+paraV.replace(///g,"//").replace(///g,"//").replace(/'/g,"/'").replace(/"/g,"/"").split(' ').join(""); document.writeln("")+"")";
}
 
 
function js2html(paraV)
{
    
return paraV.replace(/document.writeln("/g,"").replace(/");/g,"").replace(//"/g,""").replace(//'/g,""").replace(g,"/").replace(g,"/");
}

function doShift(v)
{
doConvert();

</script>
</head>
<body>
<div id="head">
<div id="oper">
<label><input type=radio value="html2js" name="c" id="ConvertType1" οnclick="doShift()" checked>HTMLtoJS</label>
&nbsp;
<label><input type=radio value="js2html" name="c" id="ConvertType2" οnclick="doShift()">JStoHTML</label>
</div>
<input type=button value=" 关闭 " οnclick="self.close()" name="close" /></div>
<div id="convert">
源内容:
<textarea id="oSource" onpropertychange="doConvert()"></textarea>
<br/><br/>
转换结果:
<textarea id="oResult" title="双击复制" οndblclick=
'this.select();oResult.createTextRange().execCommand("Copy")'></textarea>
</div>
<div id="foot"><a href="http://blog.csdn.net/sea0x/">Sea</a> test... </div>
</body>
</HTA>
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值