[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复  ygqiang


    你到底有没有看 5 楼链接?他发的东西都已经写得那么清楚了
CrLf 发表于 2016-3-17 21:18


    网上现成的例子也有,缩放网页字体:
  1. www.jq22.com/demo/286f2b4a-484c-11e4-b680-00163e001348/
复制代码
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

楼主的代码…
我有强迫症。
  1. <HTA:APPLICATION ID="screen"
  2. APPLICATIONNAME="myApp1"
  3. contextMenu ="no"
  4. BORDER="none"
  5. innerBorder="no"
  6. SHOWINTASKBAR="yes"
  7. SINGLEINSTANCE="yes"
  8. SYSMENU="no"
  9. VERSION="1.0"
  10. WINDOWSTATE="maximize"
  11. ICON="taskmgr.exe"
  12. />
  13. <html lang="cn">
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  16. <script language="JavaScript" type="text/javascript">
  17. function changeFontSize() {
  18. var w = document.body.clientWidth;
  19. var h = document.body.clientHeight;
  20. var size = w/3; size2 = w/9;
  21. if (w > 2000) {
  22. size = w/3;
  23. } else  {
  24. size = w/3;
  25. }
  26. document.getElementById("curtime").style.fontSize = "" + size + "px";
  27. document.getElementById("cursec").style.fontSize = "" + size2 + "px";
  28. document.getElementById("curdate").style.fontSize = "" + size2 + "px";
  29. document.getElementById("curweek").style.fontSize = "" + size2 + "px";
  30. }
  31. function SetTimeText() {
  32. var dt1=new Date();
  33. document.getElementById("curtime").innerHTML = dt1.getHours() + ":" + ("00" + dt1.getMinutes()).slice(-2);
  34. document.getElementById("cursec").innerHTML = ("00" + dt1.getSeconds()).slice(-2);
  35. document.getElementById("curdate").innerHTML= dt1.getMonth() + "-" + dt1.getDate();
  36. document.getElementById("curweek").innerHTML = "周" + "日一二三四五六".substr(dt1.getDay(), 1);
  37. }
  38. window.onload = function(){
  39. SetTimeText();
  40. changeFontSize();
  41. setInterval(SetTimeText, 500);
  42. setInterval(changeFontSize, 1000);
  43. };
  44. function closeWindow() {
  45. try {
  46. var Shell = new ActiveXObject("Shell.Application");
  47. Shell = null;
  48. window.close();
  49. } catch(e) {}
  50. }
  51. </script>
  52. <style type="text/css">
  53. strong {display: inline}
  54. </style>
  55. </head>
  56. <body bgcolor="#000000" bordercolor="#000000" scroll="no" onclick="closeWindow()" onkeyup="closeWindow()">
  57. <table style="width:100%; height:100%; text-align:center">
  58. <tr>
  59. <td>
  60. <strong id=curtime style="font-size:400px;color:#ffffff;font-family:黑体" /></strong>
  61. <strong id=cursec style="font-size:50px;color:#ffffff;margin-left: 8px;"/></strong><br/>
  62. <strong id=curdate style="font-size:50px;color:#ffffff;font-family:黑体;margin-left: 50px;" /></strong>
  63. <strong id=curweek style="font-size:50px;color:#ffffff;font-family:黑体;margin-left: 50px;" /></strong>
  64. </td>
  65. </tr>
  66. </table>
  67. </body>
  68. </html>
复制代码
1

评分人数

    • CrLf: 强迫症技术 + 1
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 17# yu2n


    你这代码,星期不显示。。。只显示3个框框

TOP

刚刚写的,试试吧。

Timer & Color
http://7i7hsj.com1.z0.glb.clouddn.com/ColorTimer.html
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 19# yu2n


    多谢。。

你这个有几个小问题。
1、IE提示有限制。每次都要用鼠标点击下:运行阻止的内容。才能继续运行。
2、颜色不够鲜艳。最好是黑色背景/白色数字
3、不能全屏显示。除了时间/日期/星期,其他按钮、按键啥的都不显示。
4、时间/日期/星期,字体大小。根据显示器大小/分辨率高低,自动缩小放大。
  1. <script language=vbscript>
  2. For Each Proc In GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from Win32_Process Where Name = 'mshta.exe'")
  3. if instr(Proc.commandline,location.pathname) then
  4. if proc.Priority>9 then  '检查进程优先级是否为设置值10,是则为已运行的原进程
  5.     if  msgbox("程序已运行, 重新运行请按确认!", VbOK+vbInformation)<>1 then window.close() else Proc.Terminate
  6.   else proc.SetPriority(32768)'64低 16384低于标准 32标准 32768高于标准 128高 256高(实时?)
  7.   end if
  8. end if
  9. Next
  10. </script>
  11. <script language=vbscript>
  12. RecTimer=Window.setInterval("PausedSection(0)",500)  //  window.clearInterval(RecTimer)  
  13. function  PausedSection(rush)
  14. ON Error resume Next
  15. changeFontSize
  16. document.getElementById("curtime").innertext=Hour(Now)&":"&right("0"&Minute(Now),2)
  17. document.getElementById("cursec").innertext=right("0"&Second(Now),2)
  18. document.getElementById("curdate").innertext=Month(Now)&"-"&day(Now)
  19. document.getElementById("curweek").innertext="周"& mid("日一二三四五六",Weekday(Now),1)
  20. End function
  21. </script>
  22. <script language="JavaScript" type="text/javascript">
  23.     function changeFontSize() {
  24.         var w = document.body.clientWidth /1.5
  25.         //var h = document.body.clientHeight
  26.         var size = w/1.8;
  27.         if (w > 2000) {
  28.             size = w/1.8;
  29.         } else  {
  30.             size = w/1.8;
  31.         }
  32.         document.getElementById("curtime").style.fontSize = ""+size+"px";
  33.         var size2 = w/9;var size3 = w/5;
  34.         document.getElementById("cursec").style.fontSize = "" + size2 + "px";
  35.         document.getElementById("curdate").style.fontSize = "" + size2 + "px";
  36.         document.getElementById("curweek").style.fontSize = "" + size3 + "px";
  37.     }
  38.     //setInterval( changeFontSize,100);
  39. </script>
  40. <body   bgcolor=#000000 bordercolor=#000000 >
  41.     <table style="width:100%; height:100%; text-align:center">
  42.         <tr>
  43.             <td>
  44. <strong><a id=curtime style="font-size:800px;color:#ffffff;font-family:黑体" /><p></strong>
  45. <strong><a id=curdate style="font-size:100px;color:#ffffff;font-family:黑体;margin-left: 2px;" /></strong>
  46. <strong><a id=curweek style="font-size:100px;color:#ffffff;font-family:黑体;margin-left: 100px;" /></strong>
  47.             </td>
  48.         </tr>
  49.     </table>
  50. <body scroll=no bgcolor=#000000 bordercolor=#000000 onclick=window.close() onkeyup=window.close()>
  51. <HTA:APPLICATION ID="screen"
  52. APPLICATIONNAME="myApp123"
  53. contextMenu ="no"
  54. BORDER="none"
  55. innerBorder="no"
  56. CAPTION="no"
  57. maximizebutton="yes"
  58. minimizebutton="yes"
  59. SHOWINTASKBAR="yes"
  60. SINGLEINSTANCE="yes"
  61. SYSMENU="no"
  62. VERSION="1.0"
  63. WINDOWSTATE="maximize"
  64. ICON="taskmgr.exe"
  65. />
复制代码

TOP

回复 20# ygqiang


    IE下面的 split() 有个BUG, 与chrome不一致:
  1. console.log('rgb(1, 2, 3)'.split(/\D+/).join(', '));
复制代码
所以导致了出错。改用 match 方法就可以了。

试试:
http://7i7hsj.com1.z0.glb.clouddn.com/ColorTimer1.html
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 21# yu2n


    什么版本的IE?IE9的运行结果是:日志: ,1,2,3,

TOP

回复 22# CrLf


    Windows 7 x64 IE8.0
  1. >>console.log('rgb(1, 2, 3)'.split(/\D+/).join(', '));
  2. 日志: 1, 2, 3
复制代码
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 21# yu2n


    http://7i7hsj.com1.z0.glb.clouddn.com/ColorTimer1.html

你好。非常感谢。请教2个小问题。
1、win7 64系统,IE9 浏览器。这个网页源代码,保存成1.hta。为啥不显示:星期?
2、winxp系统,IE8浏览器。弹出错误提示窗口。
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <HTA:APPLICATION ID="screen"
  3. APPLICATIONNAME="myApp1"
  4. contextMenu ="no"
  5. BORDER="none"
  6. innerBorder="no"
  7. SHOWINTASKBAR="yes"
  8. SINGLEINSTANCE="yes"
  9. SYSMENU="no"
  10. VERSION="1.0"
  11. WINDOWSTATE="maximize"
  12. ICON="taskmgr.exe"
  13. />
  14. <html lang="cn">
  15. <head>
  16. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  17. <title>Timer & Color</title>
  18. <script language="JavaScript" type="text/javascript">
  19. /**
  20. * HSL颜色值转换为RGB.
  21. * 换算公式改编自 http://en.wikipedia.org/wiki/HSL_color_space.
  22. * h, s, 和 l 设定在 [0, 1] 之间
  23. * 返回的 r, g, 和 b 在 [0, 255]之间
  24. *
  25. * @param   Number  h       色相
  26. * @param   Number  s       饱和度
  27. * @param   Number  l       亮度
  28. * @return  Array           RGB色值数值
  29. */
  30. function hslToRgb(h, s, l){
  31. var r, g, b;
  32. if(s == 0){
  33. r = g = b = l; // achromatic
  34. }else{
  35. var hue2rgb = function hue2rgb(p, q, t){
  36. if(t < 0) t += 1;
  37. if(t > 1) t -= 1;
  38. if(t < 1/6) return p + (q - p) * 6 * t;
  39. if(t < 1/2) return q;
  40. if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
  41. return p;
  42. }
  43. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  44. var p = 2 * l - q;
  45. r = hue2rgb(p, q, h + 1/3);
  46. g = hue2rgb(p, q, h);
  47. b = hue2rgb(p, q, h - 1/3);
  48. }
  49. return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
  50. }
  51. /**
  52. * RGB 颜色值转换为 HSL.
  53. * 转换公式参考自 http://en.wikipedia.org/wiki/HSL_color_space.
  54. * r, g, 和 b 需要在 [0, 255] 范围内
  55. * 返回的 h, s, 和 l 在 [0, 1] 之间
  56. *
  57. * @param   Number  r       红色色值
  58. * @param   Number  g       绿色色值
  59. * @param   Number  b       蓝色色值
  60. * @return  Array           HSL各值数组
  61. */
  62. function rgbToHsl(r, g, b){
  63. r /= 255, g /= 255, b /= 255;
  64. var max = Math.max(r, g, b), min = Math.min(r, g, b);
  65. var h, s, l = (max + min) / 2;
  66. if(max == min){
  67. h = s = 0; // achromatic
  68. }else{
  69. var d = max - min;
  70. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  71. switch(max){
  72. case r: h = (g - b) / d + (g < b ? 6 : 0); break;
  73. case g: h = (b - r) / d + 2; break;
  74. case b: h = (r - g) / d + 4; break;
  75. }
  76. h /= 6;
  77. }
  78. return [h, s, l];
  79. }
  80. //RGB转HEX
  81. function rgb2hex(rgb) {
  82. if (rgb.charAt(0) == '#') return rgb;
  83. function zero_fill_hex(num, digits) {
  84. var s = num.toString(16);
  85. while (s.length < digits) s = "0" + s;
  86. return s;
  87. };
  88. if (/rgb\(\d+, \d+, \d+\)/.test(rgb)) {
  89. var ds = rgb.match(/\d+/g);;
  90. var decimal = Number(ds[0]) * 65536 + Number(ds[1]) * 256 + Number(ds[2]);
  91. return "#" + zero_fill_hex(decimal, 6);
  92. };
  93. }
  94. //改变色调
  95. var HueSign = []; //色调符号
  96. function changColor(obj,uuid,type,step) {
  97. if (!HueSign[uuid]) HueSign[uuid] = 1;
  98. var rgb = obj.style[type];
  99. var hex = (rgb2hex(rgb)).substring(1);
  100. var r = parseInt("0x" + hex.substr(0,2));
  101. var g = parseInt("0x" + hex.substr(2,2));
  102. var b = parseInt("0x" + hex.substr(4,2));
  103. var hsl = rgbToHsl(r,g,b);
  104. var h = Math.round(hsl[0] * 2400)/10;
  105. var s = Math.round(hsl[1] * 2400)/10;
  106. var l = Math.round(hsl[2] * 2400)/10;
  107. h = h + HueSign[uuid] * step * 1; //修改色调
  108. if (h <= 0 || h >= 240) HueSign[uuid] = -1 * HueSign[uuid];
  109. if (h <= 0) h = 0;
  110. if (h >= 240) h = 240;
  111. var rgb = hslToRgb(h/240, s/240, l/240);
  112. hex = rgb2hex('rgb(' + rgb.join(', ') + ')');
  113. obj.style[type] = hex;
  114. return(true);
  115. }
  116. </script>
  117. <script language="JavaScript" type="text/javascript">
  118. //设置字体大小位置
  119. var LastSize = []; //记录最后的大小
  120. function changeFontSize() {
  121. var w = document.documentElement.clientWidth;
  122. var h = document.documentElement.clientHeight;
  123. if ((LastSize['Width'] != w) || (LastSize['Height'] != h)) {
  124. LastSize['Width'] = w;
  125. LastSize['Height'] = h;
  126. var size = w/100;
  127. document.getElementById("curtime").style.fontSize = "" + parseInt(size * 35) + "px";
  128. document.getElementById("cursec").style.fontSize = "" + parseInt(size * 10) + "px";
  129. document.getElementById("curdate").style.fontSize = "" + parseInt(size * 15) + "px";
  130. document.getElementById("curweek").style.fontSize = "" + parseInt(size * 15) + "px";
  131. var center = document.getElementById("center");
  132. center.style.left = (w - center.clientWidth)/2 + "px";
  133. center.style.top = (h - center.clientHeight)/2 + "px";
  134. }
  135. }
  136. //显示时间
  137. function SetTimeText() {
  138. var dt1=new Date();
  139. document.getElementById("curtime").innerHTML = dt1.getHours() + ":" + ("00" + dt1.getMinutes()).slice(-2);
  140. document.getElementById("cursec").innerHTML = ("00" + dt1.getSeconds()).slice(-2);
  141. document.getElementById("curdate").innerHTML= dt1.getMonth() + "-" + dt1.getDate();
  142. document.getElementById("curweek").innerHTML = "周" + "日一二三四五六".substr(dt1.getDay(), 1);
  143. }
  144. window.onload = function(){
  145. //关闭窗口(HTA)
  146. function closeWindow() {
  147. try {
  148. var Shell = new ActiveXObject("Shell.Application");
  149. Shell = null;
  150. window.close();
  151. } catch(e) {}
  152. }
  153. document.body.onclick = function(){ closeWindow(); };
  154. document.body.onkeyup = function(){ closeWindow(); };
  155. //显示时间
  156. SetTimeText();
  157. changeFontSize();
  158. setInterval(function(){
  159. SetTimeText();
  160. changeFontSize();
  161. }, 500);
  162. //修改颜色
  163. document.body.style['backgroundColor'] = '#336699';
  164. document.body.style['color'] = '#FFFFFF';
  165. setInterval(function(){
  166. //changColor(document.body, 'body::color', 'color', 1);
  167. changColor(document.body, 'body::backgroundColor', 'backgroundColor', 1);
  168. }, 50);
  169. };
  170. </script>
  171. <style type="text/css">
  172. #center {position: absolute; }
  173. #center strong {display: inline; padding: 2%; font-family:SimHei,"Microsoft YaHei","Microsoft JhengHei",DFKai-SB,SimSun;}
  174. </style>
  175. </head>
  176. <body scroll="no">
  177.     <div id='center'>
  178. <strong id="curtime" /></strong><strong id="cursec" /></strong>
  179. <br/>
  180. <center><strong id="curdate" /></strong><strong id="curweek" /></strong></center>
  181.     </div>
  182. </body>
  183. </html>
复制代码
1

评分人数

    • pcl_test: 已有链接,勿重复贴码PB -30

TOP

回复 24# ygqiang

编码不对应

TOP

回复 25# pcl_test


    能否帮忙修改下24楼的2个问题?谢谢了。

TOP

回复 26# ygqiang


    使用记事本打开源代码,依次点击菜单上“文件”-“另存为”,在“另存为”对话框中,编码选择“utf-8”,点“保存”。
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 26# ygqiang

用英文吧
document.getElementById("curweek").innerHTML = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][dt1.getDay()];

TOP

回复 27# yu2n


    多谢。。win7 64和xp系统下测试通过。

能否将秒,靠近左边的时间一点?谢谢。

TOP

回复 29# ygqiang

替换CSS为:
  1. <style type="text/css">
  2. #center {position: absolute; }
  3. #center span {display: inline; font-weight:bold; font-family:SimHei,"Microsoft YaHei","Microsoft JhengHei",DFKai-SB,SimSun;}
  4. #center span #curtime,#cursec {padding:1.5%;}
  5. #center span #curdate,#curweek {padding:2%;}
  6. </style>
复制代码
完整代码:
    http://7i7hsj.com1.z0.glb.clouddn.com/ColorTimer2.html
1

评分人数

『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

返回列表