Js与Html互转的一个hta的小工具
来源:互联网 发布:tcl电视网络电视看不了 编辑:程序博客网 时间:2024/06/06 10:53
最近对脚本有点感兴趣了..自己试着搞了个小东西出来..
<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(500, 540);
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" onclick="doShift()" checked>HTMLtoJS</label>
<label><input type=radio value="js2html" name="c" id="ConvertType2" onclick="doShift()">JStoHTML</label>
</div>
<input type=button value=" 关闭 " onclick="self.close()" name="close" /></div>
<div id="convert">
源内容:
<textarea id="oSource" onpropertychange="doConvert()"></textarea>
<br/><br/>
转换结果:
<textarea id="oResult" title="双击复制" ondblclick='this.select();oResult.createTextRange().execCommand("Copy")'></textarea>
</div>
<div id="foot"><a href="http://blog.csdn.net/sea0x/">Sea</a> test... </div>
</body>
</HTA>
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(500, 540);
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" onclick="doShift()" checked>HTMLtoJS</label>
<label><input type=radio value="js2html" name="c" id="ConvertType2" onclick="doShift()">JStoHTML</label>
</div>
<input type=button value=" 关闭 " onclick="self.close()" name="close" /></div>
<div id="convert">
源内容:
<textarea id="oSource" onpropertychange="doConvert()"></textarea>
<br/><br/>
转换结果:
<textarea id="oResult" title="双击复制" ondblclick='this.select();oResult.createTextRange().execCommand("Copy")'></textarea>
</div>
<div id="foot"><a href="http://blog.csdn.net/sea0x/">Sea</a> test... </div>
</body>
</HTA>
- Js与Html互转的一个hta的小工具
- 一个html截取字符串的小工具
- Html代码转化为Js的小工具
- 将html代码转换成js字符串的小工具
- 写一个生成html文档的小工具。
- 一个倒计时的小工具
- 一个Python的小工具
- 一个 popupwindow的小工具
- C# WPF 小工具HTML转JS
- 【小工具】原生JS的计算器
- 在写JS时的小工具
- 自编自用的歌曲整理程序 js+html+hta
- 自动检测代码的一个小工具...
- 一个文件修改监视的小工具
- 一个远程系统控制台的小工具
- 一个值得收藏的小工具
- MD5加密的一个小工具
- 一个简单的猴子测试小工具
- 第 5 章 雀跃吧!超脱了一切的弹出窗口
- 第 6 章 奔腾吧!让不同的浏览器里显示一样的布局
- 第 7 章 低鸣吧!拖拽就像呼吸一样容易
- 第 8 章 哭泣吧!现在才开始讲基础问题
- 第 9 章 沉寂吧!我们要自己的控件
- Js与Html互转的一个hta的小工具
- 附录 A. 常见问题乱弹
- 附录 C. 后记
- 闹钟C语言
- Microsoft Windows的历史
- J2EE Clustering经典范文学习
- Const in C++
- csdn的登录验证做的太有“准”啦
- Java学习笔记1------c#和Java的区别