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.getEle mentById("butto n1").blink = function (duration)
{
var that = this;
var originalDisplay = that.getAttribu te("display");
var newDipslay;
if (originalDispla y === undefined ||
originalDisplay == "")
{
originalDisplay = "inline";
newDisplay = "none";
}
else
{
originalDisplay = "none";
newDisplay = "inline";
}
that.setAttribu te("display",ne wDisplay);
setTimeout(func tion ()
{that.setAttrib ute("display",o riginalDisplay) ;that=null;},du ration);
// setTimeout(func tion () {alert('asdf'); },duration);
};
document.getEle mentById("butto n1").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.getEle mentById("butto n1").blink = function (duration)
{
var that = this;
var originalDisplay = that.getAttribu te("display");
var newDipslay;
if (originalDispla y === undefined ||
originalDisplay == "")
{
originalDisplay = "inline";
newDisplay = "none";
}
else
{
originalDisplay = "none";
newDisplay = "inline";
}
that.setAttribu te("display",ne wDisplay);
setTimeout(func tion ()
{that.setAttrib ute("display",o riginalDisplay) ;that=null;},du ration);
// setTimeout(func tion () {alert('asdf'); },duration);
};
document.getEle mentById("butto n1").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.
Comment