Esta página foi traduzida do inglês pela comunidade.Saiba mais e junte-se à comunidade MDN Web Docs.
Document.bgColor
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see thecompatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
A propriedade obsoletabgColor obtém ou atribue a cor de fundo do documento atual.
In this article
Sintaxe
color = document.bgColordocument.bgColor = color
Parâmetros
coloré uma sequência de caracteres representando a cor como uma palavra (p. ex. "red") ou um valor hexadecimal (p. ex. "#ff0000").
Exemplo
document.bgColor = "darkblue";
Notas
O valor padrão para esta propriedade no Firefox é branco (#ffffff em hexadecimal).
document.bgColor está obsoleto noDOM Level 2 HTML. A alternativa recomendada é fazer uso do atributo CSSbackground-color que pode ser acessado através do DOM comdocument.body.style.backgroundColor. Uma outra alternativa é odocument.body.bgColor, apesar dessa também estar obsoleta no HTML 4.01 em funcão da alternativa do CSS.