找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 7390|回复: 1

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

[复制链接]
发表于 2025-3-12 16:46:41 | 显示全部楼层 |阅读模式
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>
复制代码
发表于 2025-3-17 14:00:03 | 显示全部楼层
本帖最后由 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技术 +1 收起 理由
zzz19760225 + 1 多谢!

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 05:41 , Processed in 0.022200 second(s), 12 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表