P
Paul Randall
"MikeB" <m.byerleyATVerizonDottieNettie> wrote in message
<html>
<HEAD>
<TITLE>This is the Application Caption</TITLE>
<HTA:APPLICATION ID="oApp"
APPLICATIONNAME="Splash Screen"
BORDER="thick"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
CAPTION="YES"
ICON=""
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal">
<style type="text/css">
.textBlack {
color : #000000;}
.textRed {
color : #CC0000;
}
</style>
<SCRIPT type="text/javascript">
var bBlinkON = false;
function SwapColors(valIN)
{
if (valIN.className=='textBlack')
valIN.className='textRed';
else
valIN.className='textBlack';
return;
}
function Init()
{
var fSC = function (){
SwapColors(window.document.getElementById('spanToBlink'))};
var UpdateTime = window.setInterval(fSC,1000);}
function Terminate()
{
window.clearTimeout();
}
</SCRIPT>
</HEAD>
<body onload="Init(); return false;">
<div><span id="spanToBlink" class="textBlack">This is my blinking
Text!</span>
</div>
</body>
</html>
Thanks Mike! Your code works.
Now the question is, how do I insert your javascript code into the HTA
that I referred to:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0130.mspx
The resulting HTA needs to have both VBScript and javascript code.
What I'm looking for is the HTA to have a blank span initially; and
then when I click the button, the text of my choosing appears, and it
starts blinking in the manner that your javascript code commands it to
do.
Thanks!
- Dave
Hi, Dave
If you don't already have it, download the HTA HelpOMatic.hta from
here:
http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=hta&DisplayLang=en
A basic HTA looks like this:
<html>
<head>
<title>Put your window title bar here</title>
<script language="vbscript">
'Putting this script here prepositions the window.
'Windowstate=Maximize would override this.
Const wdDlg = 600, htDlg = 380 ' dialog size
Const pxLeft = 100, pxTop = 100 ' positioning
window.ResizeTo wdDlg,htDlg
window.MoveTo pxLeft,pxTop
</SCRIPT>
<HTA:APPLICATION
ID="Put your ID here"
APPLICATIONNAME="Put your application name here"
SCROLL="yes"
SINGLEINSTANCE="no"
WINDOWSTATE=""</head>
<SCRIPT Language="VBScript">
</SCRIPT>
<SCRIPT Language="JScript">
</SCRIPT>
<body>
</body>
</html>
The script near the beginning is something I've picked up in the M$
scripting newsgroup -- By being before the <HTA: ... > element, it
positions and sizes the HTA window before it is desplayed.
You can sprinkle <script> ... </script> blocks essentially anywhere
between the <head> and </html> tags. Each script block can specify
the language it uses; other languages like Perl, Python, Ruby, Rex,
and others can be installed. One hta can use a mixture of all the
scripting languages you have installed. Placing all the scripts in
front of the <body> tag helps with readability
You probably already know that subroutines and functions can be
specified to run when certain events associated with some object
occur. For example, the HTML for a button can specify a subroutine
name and arguments to be passed when the button's OnClick event is
invoked. Besides specifying the language, the <script ...> tag can
specify an object and an event name; the script within this script
block will only be executed in response to this event. Details of the
<script > element syntax is here:
http://msdn2.microsoft.com/en-us/library/ms535892(VS.85).aspx#
Functions and subroutines within the <script> ... </script> blocks are
only executed when they are called. The same is true when the <script
....> tag indicates that it is for a specific event for a specific
object. All other script is executed as it is encountered. You might
call this script the main program, although it can be parts of many
<SCRIPT type="text/javascript">
var bBlinkON = false;
Variable bBlinkON is defined outside any function/sub, so it is a
global variable available immediately to any line of JScript executed
at a later time.
Some of the things you have to do are:
-copy the JScript blocks to some place ahead of your <body ... > tag.
-modify your <body ... > tag to set up event handlers.
-modify the script to use your span's ID.
-Add a button & click handler to modify the text in the span.
As demonstrated in the blinking code, you can get a reference to your
span with code like:
window.document.getElementById('spanToBlink')
As with most elements, this element has an innerhtml property which
you can change to any text you want.
If you find the HTA helpOMatic.hta handy, you can customize it --
adding selection items and HTML blocks and associated script blocks or
modifying the current ones to your liking.
-Paul Randall