.BMP文件可以存储在HTA(HTML / VBScript)中吗?

我注意到在我的FireFox书签的备份中,显示在每个条目左侧的图标被保存为A标签中的字符流.例如:

ICON=”data:image/png;base64,iVBOR [data removed to shorten example]
rkJggg==”

我有3个BMP文件(2个是4×20(249字节),1个是102×82(24.7 KB)),我想隐藏在我的HTML应用程序中,以免丢失.

较大的一个在样式标签中出现3次,如下所示(1个出现):

<style type="text/css">
#frmMainBody
  {background:grey; background-image:url('Background.bmp'); margin:0;
   padding:0; font:normal 10pt Microsoft Sans Serif;}
</style>

另外两个出现在VBScript子程序中,如下所示:

Sub Button_Glow
  ' Highlights a button when the cursor hovers over it.

  With Window.Event.srcElement.Style
    If .BackgroundColor <> "Lavender" Then
      .BackgroundColor = "Lavender"
      .BackgroundImage = "url(Glow.bmp)"
      .BackgroundPositionY = -2
      .BackgroundRepeat = "Repeat-X"
    End If
  End With

End Sub 'Button_Glow

这可能吗 ?

解决方法

HTA是一种纯文本可编辑标记语言,您可以使用任何纯文本编辑器(如记事本)打开和编辑.

您可以通过将图像转换为base64,然后代替,将任何图像格式存储在HTML,CSS等中

<img src="mypath/myimage.bmp" />

<style type="text/css">
foo { background: url(mypath/myimage.bmp); }
</style>

你会把::

<img src="data:image/x-png;base64,iVBORw0KGgoAAAANS....." />

<style type="text/css">
foo { background: url(data:image/x-png;base64,iVBORw0KGgoAAAANS.....); }
</style>

为了使您更容易,您可以使用在线工具(如位于此处>>>>)将图像转换为此格式. Convert any Image into a Base64 string< . 如何在您的问题中将此代码应用于代码 使用其中一个工具(或编写自己的),找到并将“Background.bmp”转换为base64,然后修改您发布的第一个代码块(也缩短为节省空间)

<style type="text/css">
#frmMainBody
  {background:grey; background-image:url(data:image/x-png;base64,iVBORw0KGgoAAAANS....); margin:0;
   padding:0; font:normal 10pt Microsoft Sans Serif;}
</style>

接下来,对于VBScript代码,找到并转换’Glow.bmp'(与上面对’Background.bmp’所做的一样),并修改代码块,使其看起来像

Sub Button_Glow
  ' Highlights a button when the cursor hovers over it.

  With Window.Event.srcElement.Style
    If .BackgroundColor <> "Lavender" Then
      .BackgroundColor = "Lavender"
      .BackgroundImage = "data:image/x-png;base64,iVBORw0KGgoAAAANS....."
      .BackgroundPositionY = -2
      .BackgroundRepeat = "Repeat-X"
    End If
  End With

End Sub

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些