/    Sign up×
Community /Pin to ProfileBookmark

flashing tbale border in FileFox

Hi.
I tried to get a flashing table bordr, it worked OK in IE 6 but NOT if FF.
I found the the problem is:
FF can WRITE getElementById but it CAN NOT READ IT ?
so I found an “Elegant” way to bypass it by creating a dummy color variable: col
the table is:
<table border=”0″ id=”table” style=”border: 4px blue solid;”>
…..
</table>

<script language=”javascript”>
var col = ‘blue’
function flasher() {
if(col == ‘blue’) {
document.getElementById(‘table’).style.borderColor = ‘red’
col = ‘red’
} else {
document.getElementById(‘table’).style.borderColor = ‘blue’
col = ‘blue’
}
setTimeout(“flasher()” , 1000)
}
</script>
<script language=”javascript”>flasher();</script>

It works in both IE6 and FF 3.
see a demo: [URL=”http://www.the-secret-of-SEO.com”]www.the-secret-of-SEO.com[/URL]

?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Y_LessMay 26.2009 — Firstly, that's got nothing to do with FF's use of getElementById, it's because first time FF calls that function the style is not stored on the element, it's in a style attribute, which for some reason it treats differently. Where you have:

col = blue;[/col]

Do:

[code]document.getElementById('table').style.borderColor = 'blue'


Then your original IE code should work on FF too. Or, better yet, do:

var elStyle = document.getElementById('table').style;
elStyle.borderColor = 'blue';


Saves a lot of time in subsequent uses if you use that variable instead.
×

Success!

Help @Lazer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...