JavaScript DHTML/Style Layout/Background
Содержание
"bgProperties" Example
<source lang="html4strict">
<html> <head> <script>
function function1() { document.all.myBody.bgProperties = "fixed"; }
</script> </head> <body background="http://www.wbex.ru/style/logo.png"
onclick="function1();" id="myBody">
</body> </html>
</source>
div.style.backgroundColor="#00f";
<source lang="html4strict">
<html> <head> <title>PrettyPretty</title> <script type="text/javascript"> document.onclick=changeElement; function changeElement() {
var div = document.getElementById("div1"); div.style.backgroundColor="#00f"; div.style.width="500px"; div.style.color="#fff"; div.style.height="200px"; div.style.paddingLeft="50px"; div.style.paddingTop="50px"; div.style.fontFamily="Verdana"; div.style.fontSize="2em"; div.style.border="3px dashed #ff0"; div.style.position="absolute"; div.style.left="200px"; div.style.top="100px"; div.style.textDecoration="underline";
} </script> </head> <body>
This is a DIV element. Click me to see the change.
</body> </html>
</source>
Get and set node background color
<source lang="html4strict">
<html> <head> <title>The Node</title> <script type="text/javascript"> function outputNodeProps(nd) {
var strNode = "Node Type: " + nd.nodeType; strNode += "\nNode Name: " + nd.nodeName; strNode += "\nNode Value: " + nd.nodeValue; if (nd.style) { var clr = "red"; nd.style.backgroundColor=clr; strNode += "\nbackgroundColor: " + clr; } alert(strNode);
} </script> <body onload="outputNodeProps(document)">
Header
</body> </html>
</source>