/    Sign up×
Community /Pin to ProfileBookmark

Set the bgcolor attribute value

Hi,

The following doesn’t work:

[CODE]<!DOCTYPE HTML>
<title>Test</title>
<embed id=”foo” src=”http://www.w3schools.com/media/bookmark.swf” width=”400″ height=”40″ type=”application/x-shockwave-flash” />

<script type=”text/javascript”>
document.getElementById(“foo”).setAttribute(“bgcolor”, “#00FF00”);
</script>[/CODE]

But if you change [I]setAttribute[/I] to [I](“width”, “800”)[/I], it works with no problem! What am I missing?

Any help is appreciated!
Mike

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@balazblogspotJul 22.2011 — This code works for me in IE8 and FF4. Background changes to green. What browser are you using?


My blog:http://www.balazblogspot.blogspot.com/
Copy linkTweet thisAlerts:
@mmantarasJul 22.2011 — if you want to change de background color from javascript you must do like that

document.getElementById("some_element").style.backgroundColor="some_color";


Best Regards
Copy linkTweet thisAlerts:
@Rain_LoverauthorJul 24.2011 — This code works for me in IE8 and FF4. Background changes to green. What browser are you using?


My blog:http://www.balazblogspot.blogspot.com/[/QUOTE]


IE8 and the latest versions of Firefox, Chrome, Opera and Safari. But as you said it works in IE8.
Copy linkTweet thisAlerts:
@Rain_LoverauthorJul 24.2011 — if you want to change de background color from javascript you must do like that

document.getElementById("some_element").style.backgroundColor="some_color";


Best Regards[/QUOTE]


Thanks for the answers, but they are two different things. To see what I mean please try adding bgcolor="#00FF00" to the embed code and compare it with changing the style background color.
×

Success!

Help @Rain_Lover 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.21,
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,
)...