|
http://blogs.technet.com/b/heyscriptingguy/archive/2006/07/27/how-can-i-display-a-message-box-that-has-no-buttons-and-that-disappears-after-a-specified-period-of-time.aspx
No one should have to suffer through the tedious,
condescending hamminess of "The Scripting Guys". :)
I don't see the original thread here, so forgive me if
I'm repeating anything.
Your post seems ambiguous. The title is about showing
a message in an HTA. The SG post is about showing a
custom message *in a script* by loading an HTA.
For a custom message in a script I
use a class. It's more involved than what the SG are
showing, but their code would also be very complex
once you actually flesh it out to work properly. (Also,
if it's in a script you can always use WScript.Sleep.
The custom message is the hard part, not the timer.)
See here for custom message windows that can be
controlled from within the script:
http://www.jsware.net/jsware/msggal.php5
There's a link at the bottom for the download. You
just paste the class into a script and then you can
show any sort of custom message you like.
If the message is to show in an HTA itself you
can use CSS, though it might take some fiddling
to get it to look just the way you want it. And
be sure to leave out the DOCTYPE tag if you want
it consistent in different IE versions. (Also, IE 11
does not recognize VBS in standards mode, which
is another reason to leave out DOCTYPE, using
quirks mode):
<html>
<STYLE>
#msg {position: absolute; top: 200px; left: 200px; width: 200px;
height: 100px; background-color: #FF0000; color: #FFFFFF;
font-family: verdana; font-size: 13px; text-align: center; padding:
20px;
border-style: outset; border-width: 1px; display: none;}
</STYLE>
<script language = "VBScript">
Sub But1_onclick()
ShowMsg "This is an alert", 4
End Sub
Sub ShowMsg(sMsg, LSec)
Dim s1
s1 = "msg.style.display = " & Chr(34) & "none" & Chr(34)
msg.innerText = sMsg
msg.style.display = "block"
msg.style.zIndex = 100
window.setTimeout s1, LSec * 1000, "VBScript"
End Sub
</script>
<body>
<DIV ID="msg"> </DIV>
<INPUT ID="But1" TYPE="button" VALUE=Show Message">
</body>
</html>