为什么这个hta文件在显示图像之前会闪烁一个大方块?

问题描述 投票:0回答:1

我有以下代码显示一个名为Test1.png的图像

当图像本身正确显示时,首次打开时,大的白色方块会在图像打开前闪烁一秒钟。

我怎样才能摆脱这种闪烁一秒钟的形状。

码:

<html>
    <HTA:APPLICATION ID = "oHTA"
        BORDER          = "none"
        BORDERSTYLE     = "normal"
        CAPTION         = "no"
        CONTEXTMENU     = "no"
        SYSMENU         = "no"
        NAVIGABLE       = "no"
        INNERBORDER     = "no"
        SCROLL          = "no"
        SELECTION       = "no"
        SINGLEINSTANCE  = "yes"
        WINDOWSTATE     = "normal"
        SHOWINTASKBAR   = "no"
    />
<head>
  <meta http-equiv="x-ua-compatible" content="ie=9">

  <style type="text/css">
    body {
        background-color: red; 
        border-color:     red; 
        margin-top:      -1px;
        margin-left:     -1px;
        margin-bottom:   -1px;
        margin-right:    -1px;
    }
  </style>

  <script language="VBScript">
      Option Explicit
      Dim width, height
      width  = 478 -1                 '''  
      height =  50 -1                 ''' 
      Sub window_onload()
          CenterWindow width, height
      End Sub
      Sub CenterWindow( widthX, heightY )
          self.ResizeTo widthX, heightY 
          self.MoveTo (screen.availWidth - widthX)/2, (screen.availHeight - heightY)/2
      End Sub
  </script>
</head>

<body>
  <img src="Test1.png"/>
</body>
</html>
html vbscript hta
1个回答
2
投票

当您事先知道HTA窗口的大小和位置时,请从window.onload中调整大小并重新定位,并使它们成为脚本中的第一个动作,并在重新定位/调整大小后移动<hta>标记。这是有效的,因为窗口是不可见的,直到执行<hta>之前放置的所有代码。

<html>
    <head>
        <meta http-equiv="x-ua-compatible" content="ie=9">
        <style type="text/css">
            body {
                background-color: red; 
                border-color:     red; 
                margin-top:      -1px;
                margin-left:     -1px;
                margin-bottom:   -1px;
                margin-right:    -1px;
           }
       </style>    
       <script language="VBScript">
           Option Explicit
           Dim width, height
           width  = 478 -1                 '''  
           height =  50 -1                 ''' 
           self.ResizeTo width, height 
           self.MoveTo (screen.availWidth - width)/2, (screen.availHeight - height)/2
      </script>
      <HTA:APPLICATION ID = "oHTA"
          BORDER          = "none"
          BORDERSTYLE     = "normal"
          CAPTION         = "no"
          CONTEXTMENU     = "no"
          SYSMENU         = "no"
          NAVIGABLE       = "no"
          INNERBORDER     = "no"
          SCROLL          = "no"
          SELECTION       = "no"
          SINGLEINSTANCE  = "yes"
          WINDOWSTATE     = "normal"
          SHOWINTASKBAR   = "no"
     />
</head>
© www.soinside.com 2019 - 2024. All rights reserved.