返回列表 发帖

[问题求助] [已解决]求助VBS缩小iframe里的文本文件字符?

WIN764
1.txt(里有两行16个黑方块字符)
  1. ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
  2. ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
复制代码
1.hta
  1. <html><head>
  2.     <HTA:APPLICATION
  3.          SCROLL="yes"
  4.          SINGLEINSTANCE="yes"
  5.     >
  6. <style>
  7.     body {
  8.         font-size:5px;
  9.         line-height:1;
  10.     }
  11. </style>
  12. </head><body>
  13.     <iframe src="1.txt" style="width:100%;height:50%;" ></iframe>
  14. </body></html>
复制代码
通义AI对给予的代码,没有改变。但是执行没有缩小字符,所以求助,希望能将字符缩小。

用了询问vbs解题内容,放弃iframe,通义ai一个解决代码。
  1. <html>
  2. <head>
  3. <title>显示1.txt内容</title>
  4. <HTA:APPLICATION
  5.      APPLICATIONNAME="显示1.txt内容"
  6.      SCROLL="yes"
  7.      SINGLEINSTANCE="yes">
  8. <style>
  9.     textarea {
  10.         font-size: 10px; /* 调整字体大小 */
  11.         width: 100%;
  12.         height: 90%;
  13.         resize: none;
  14.     }
  15. </style>
  16. <script language="VBScript">
  17. Sub Window_OnLoad()
  18.     Dim objFSO, objFile, strContents
  19.     Set objFSO = CreateObject("Scripting.FileSystemObject")
  20.    
  21.     If objFSO.FileExists("1.txt") Then
  22.         Set objFile = objFSO.OpenTextFile("1.txt", 1)
  23.         strContents = objFile.ReadAll
  24.         objFile.Close
  25.         
  26.         ' 将文本内容按行分割并添加到textarea中
  27.         arrLines = Split(strContents, vbCrLf)
  28.         For Each strLine In arrLines
  29.             txtContent.Value = txtContent.Value & strLine & vbCrLf
  30.         Next
  31.     Else
  32.         MsgBox "1.txt 文件不存在!", vbExclamation, "错误"
  33.     End If
  34.    
  35.     Set objFSO = Nothing
  36. End Sub
  37. </script>
  38. </head>
  39. <body>
  40. <textarea id="txtContent" readonly></textarea>
  41. </body>
  42. </html>
复制代码

本帖最后由 aloha20200628 于 2025-3-17 14:09 编辑

回复 1# zzz19760225
要缩放 iframe 窗口(自然也就缩放其内的文本元素)可用 css 的 transform: scale 功能,对于 mshta 而言,须采用 ie10+ 引擎才有效。以下代码存为 test.hta 与 1.txt 同目录运行,其中第6行的数字 0.7 是缩放值(可自定义),基于 iframe 窗口原尺寸 380x80 矩形的左上角缩放。
  1. <meta http-equiv='x-ua-compatible' content='ie=10'>
  2. <style>
  3.     .scaled {
  4.     width: 360px; height: 80px;
  5.     transform-origin: top left;
  6.         transform: scale(0.7); /* 缩小 iframe 窗口至 70% */
  7.     }
  8. </style>
  9. <iframe src="1.txt" class="scaled"></iframe>
复制代码
1

评分人数

TOP

返回列表