
标题: [问题求助] [已解决]求助VBS缩小iframe里的文本文件字符? [打印本页]
作者: zzz19760225 时间: 2025-3-12 16:46 标题: [已解决]求助VBS缩小iframe里的文本文件字符?
WIN764
1.txt(里有两行16个黑方块字符)- ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
- ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
复制代码
1.hta- <html><head>
- <HTA:APPLICATION
- SCROLL="yes"
- SINGLEINSTANCE="yes"
- >
- <style>
- body {
- font-size:5px;
- line-height:1;
- }
- </style>
- </head><body>
- <iframe src="1.txt" style="width:100%;height:50%;" ></iframe>
- </body></html>
复制代码
通义AI对给予的代码,没有改变。但是执行没有缩小字符,所以求助,希望能将字符缩小。
用了询问vbs解题内容,放弃iframe,通义ai一个解决代码。- <html>
- <head>
- <title>显示1.txt内容</title>
- <HTA:APPLICATION
- APPLICATIONNAME="显示1.txt内容"
- SCROLL="yes"
- SINGLEINSTANCE="yes">
- <style>
- textarea {
- font-size: 10px; /* 调整字体大小 */
- width: 100%;
- height: 90%;
- resize: none;
- }
- </style>
- <script language="VBScript">
- Sub Window_OnLoad()
- Dim objFSO, objFile, strContents
- Set objFSO = CreateObject("Scripting.FileSystemObject")
-
- If objFSO.FileExists("1.txt") Then
- Set objFile = objFSO.OpenTextFile("1.txt", 1)
- strContents = objFile.ReadAll
- objFile.Close
-
- ' 将文本内容按行分割并添加到textarea中
- arrLines = Split(strContents, vbCrLf)
- For Each strLine In arrLines
- txtContent.Value = txtContent.Value & strLine & vbCrLf
- Next
- Else
- MsgBox "1.txt 文件不存在!", vbExclamation, "错误"
- End If
-
- Set objFSO = Nothing
- End Sub
- </script>
- </head>
- <body>
- <textarea id="txtContent" readonly></textarea>
- </body>
- </html>
复制代码
作者: aloha20200628 时间: 2025-3-17 14:00
本帖最后由 aloha20200628 于 2025-3-17 14:09 编辑
回复 1# zzz19760225
要缩放 iframe 窗口(自然也就缩放其内的文本元素)可用 css 的 transform: scale 功能,对于 mshta 而言,须采用 ie10+ 引擎才有效。以下代码存为 test.hta 与 1.txt 同目录运行,其中第6行的数字 0.7 是缩放值(可自定义),基于 iframe 窗口原尺寸 380x80 矩形的左上角缩放。- <meta http-equiv='x-ua-compatible' content='ie=10'>
- <style>
- .scaled {
- width: 360px; height: 80px;
- transform-origin: top left;
- transform: scale(0.7); /* 缩小 iframe 窗口至 70% */
- }
- </style>
- <iframe src="1.txt" class="scaled"></iframe>
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |