F
Frank O'Hara
Hello everyone, I'm just learning some of the depth that Javascript
has to offer. I have to say that it is quite amazing. Anyway, I'm
translating some of my older, classical code to try to take advantage
of some of the new things I'm learning but I'm a little stuck with
this one (see snip):
<snip>
document.getElementById("button1").blink = function (duration)
{
var that = this;
var originalDisplay = that.getAttribute("display");
var newDipslay;
if (originalDisplay === undefined ||
originalDisplay == "")
{
originalDisplay = "inline";
newDisplay = "none";
}
else
{
originalDisplay = "none";
newDisplay = "inline";
}
that.setAttribute("display",newDisplay);
setTimeout(function ()
{that.setAttribute("display",originalDisplay);that=null;},duration);
// setTimeout(function () {alert('asdf');},duration);
};
document.getElementById("button1").blink(1000);
</snip>
This isn't working and I'm not 100% certain why not. The anonymous
function is not being called after 1000 msec (duration). I tried with
the easier, commented, line but that didn't execute either.
While I'm intrigued by the features that Javascript has to offer, I'm
finding it difficult to know when/why/where to use them. I'm sure
that will improve as I see it solve problems for me but for now I'm
feeling rather 'dumb'.
Any help would be appreciated.
Thanks,
Frank.
has to offer. I have to say that it is quite amazing. Anyway, I'm
translating some of my older, classical code to try to take advantage
of some of the new things I'm learning but I'm a little stuck with
this one (see snip):
<snip>
document.getElementById("button1").blink = function (duration)
{
var that = this;
var originalDisplay = that.getAttribute("display");
var newDipslay;
if (originalDisplay === undefined ||
originalDisplay == "")
{
originalDisplay = "inline";
newDisplay = "none";
}
else
{
originalDisplay = "none";
newDisplay = "inline";
}
that.setAttribute("display",newDisplay);
setTimeout(function ()
{that.setAttribute("display",originalDisplay);that=null;},duration);
// setTimeout(function () {alert('asdf');},duration);
};
document.getElementById("button1").blink(1000);
</snip>
This isn't working and I'm not 100% certain why not. The anonymous
function is not being called after 1000 msec (duration). I tried with
the easier, commented, line but that didn't execute either.
While I'm intrigued by the features that Javascript has to offer, I'm
finding it difficult to know when/why/where to use them. I'm sure
that will improve as I see it solve problems for me but for now I'm
feeling rather 'dumb'.
Any help would be appreciated.
Thanks,
Frank.