css - 在 HTA 中失去焦点时,按钮的虚线边框变为两条实线边框

标签 css vbscript windows-7 internet-explorer-11 hta

在我的 HTA 文件中,我使用 VBScript 在单击按钮时更改按钮的外观。单击的按钮获得虚线边框(如预期的那样)。但是当鼠标离开按钮时,虚线边框变为实线边框加上实线青色内边框。我怎样才能避免这种情况?

left: after clicking the green button, right: after the mouse has left the green button

<html> 
<head> 
    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
    <title>Dashed border test</title> 
    <HTA:APPLICATION 
        ID              = "test"
        APPLICATIONNAME = "test" >

    <script language="VBScript" type="text/vbscript">
        Sub StopButton
            document.getElementsByTagName("button").item(0).style.border="dashed medium black"
            document.getElementsByTagName("button").item(1).style.border="none"
        End Sub
        Sub PlayButton
            document.getElementsByTagName("button").item(1).style.border="dashed medium black"
            document.getElementsByTagName("button").item(0).style.border="none"
        End Sub
    </script>
    <style type="text/css">
        button {width:100;height:80;font-size:24;}
    </style>
</head> 

<body>
    <button type="button" onclick="vbscript:StopButton" style="background:blue; color:white;" value="Stop">Stop</button>
    <button type="button" onclick="vbscript:PlayButton" style="background:#0f0;" value="Play">Play</button>
</body> 
</html>

我使用 IE11。 navigator.userAgent="Mozilla/4.0(兼容;MSIE 7.0;Windows NT 6.1;WOW64;Trident/7.0;SLCC2;.NET CLR 2.0.50727;.NET CLR 3.5.30729;.NET CLR 3.0.30729;媒体中心 PC 6.0;.NET4.0C;.NET4.0E;InfoPath.3)”

编辑

附加信息:当我单击背景(白色区域)时,按钮边框变回虚线样式(如左图所示)。

最佳答案

我是这样解决的。

首先,您打开一个保存在内存中的全局变量。因此,当用户单击任一选项时。单击它后,这些选项可帮助它防止突出显示 html 元素的默认颜色。

<html> 
<head> 
    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
    <title>Dashed border test</title> 
    <HTA:APPLICATION 
        id              = "test"
        applicationname = "test" 
        singleinstance="yes"
        contextmenu="yes"
        navigable="yes"
    />

    <script language="vbscript" type="text/vbscript">
        stopclicked=false
        playclicked=false
        sub stopbutton(click)
            if ((click = true) OR (stopclicked = true)) then
                btnplay.classname="none"
                btnstop.classname="dashed"
                stopclicked=true
                playclicked=false
            else
                window.focus
            end if
        end sub
        sub playbutton(click)
            if ((click = true) OR (playclicked = true)) then
                btnplay.classname="dashed"
                btnstop.classname="none"
                stopclicked=false
                playclicked=true
            else
                window.focus
            end if
        end sub
    </script>
    <style type="text/css">
        button {width:100; height:80; font-size:24;}
        .dashed {border-style: dashed; border-style: black; border-style:medium;}
        #btnstop {background:blue; color:white;}
        #btnplay {background:#0f0;}
        .dashed:
    </style>
</head> 

<body link="" vlink="" alink=""> 
    <button id="btnstop" onclick="stopbutton(true)" onfocus="stopbutton(false)" value="Stop">Stop</button>
    <button id="btnplay" onclick="playbutton(true)" onfocus="playbutton(false)" value="Play">Play</button>
</body> 
</html>

关于css - 在 HTA 中失去焦点时,按钮的虚线边框变为两条实线边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30025938/

相关文章:

html - 仅将 CSS 混合模式应用于边框

css - 从 extjs 4.2 按钮中删除/切换 CSS 类

vb6 - vbscript 与 Windows 8 的兼容性问题

vbscript - VBscript 自动格式化工具

winforms - 桌面支付处理应用程序 : Switching APIs from Authorize.Net to Paypal

html - 框阴影插图和边框 :none cause form fields to flicker in IE/Edge

html - IE8 的 CSS3 框阴影效果?

java - 如何从 asp 调用 java?

java - 为什么此代码不会导致我的计算机内存耗尽?

asp.net - 设置 IIS7.5 进行本地 ASP.Net 开发