新手问个基础问题
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script type="text/javascript"> function change() { document.bgColor = "red"; } </script></head><body><input type="text" name="color" id="color"/><input type="button" onclick="change(color)"/></body></html><html><head></head><body><input type="text" name="color" id="color"/><input type="button" onclick="change()" value="确定"/></body><script>function change(){ var color_key=document.getElementById("color").value; document.body.style.backgroundColor=color_key;}</script></html>
[解决办法]
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script type="text/javascript"> function change() { var color = document.getElementById("color").value; document.bgColor = color; } </script></head><body><input type="text" name="color" id="color"/><input type="button" onclick="change()"/></body></html>