设置bgcolor属性值 [英] Set the bgcolor attribute value

查看:168
本文介绍了设置bgcolor属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下行不通:

 <!DOCTYPE HTML> 
< title>测试< /标题>

< script type =text / javascript>
document.getElementById(foo)。setAttribute(bgcolor,#00FF00);
< / script>

但是,如果将 setAttribute 更改为 800),它没有问题!我缺少什么?



任何帮助表示赞赏!

div class =h2_lin>解决方案

根据符合规范 embed 有一个宽度属性,但没有 bgcolor 属性。



无论如何它是一个被替换的元素,所以无论它是什么颜色,它都会从Flash对象无论如何。

The following doesn't work:

<!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>

But if you change setAttribute to ("width", "800"), it works with no problem! What am I missing?

Any help is appreciated!

Mike

解决方案

According to the specification embed has a width attribute but doesn't have a bgcolor attribute.

It is a replaced element anyway, so whatever colour it is, it will take from the Flash object anyway.

这篇关于设置bgcolor属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆