Topic: 我本意是点击按钮实现背景颜色的改变,可是我只能变蓝不能变红,请教?急!

  Print this page

1.我本意是点击按钮实现背景颜色的改变,可是我只能变蓝不能变红,请教?急! Copy to clipboard
Posted by: zilin
Posted on: 2003-03-19 10:30

<html><head>
<Script Language="JavaScript">
//原来的颜色
document.bgColor="blue";
document.vlinkColor="white";
document.linkColor="yellow";
document.alinkcolor="red";
//动态改变颜色
function changecolor()
{
if (document.bgColor=="red")
  document.bgColor="blue";
else
  document.bgColor="red";
document.vlinkColor="blue";
document.linkColor="green";
document.alinkcolor="blue";
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD>
<body bgColor="#FFCCCC" >
<A href="test8_2.htm"> 调用动态按钮文档</a>
<form >
<Input type="button" Value="ChangeColor button " onClick="changecolor()">
</form>
</BODY>
</HTML>

2.Re:我本意是点击按钮实现背景颜色的改变,可是我只能变蓝不能变红,请教?急! [Re: zilin] Copy to clipboard
Posted by: floater
Posted on: 2003-03-19 23:54

add this line somewhere
alert(document.bgColor);
Then you will know what's wrong.(document.bgColor is not "red", it's #...)

3.Re:我本意是点击按钮实现背景颜色的改变,可是我只能变蓝不能变红,请教?急! [Re: floater] Copy to clipboard
Posted by: zilin
Posted on: 2003-03-20 09:36

我写了alert(document.bgColor);但是没有提示或显示任何信息

4.这是另外一个简单的问题,谢谢 [Re: zilin] Copy to clipboard
Posted by: zilin
Posted on: 2003-03-20 09:59

我认为
<%@ page import = "eoaapp.bbs.*,eoaapp.*,eoaapp.util.*,java.util.*,java.net.URLEncoder,eoaapp.filter.*"%>
和<%@ page import = "eoaapp.*,java.util.*,java.net.URLEncoder,"%>
是一样的,对吗?

5.Re:我本意是点击按钮实现背景颜色的改变,可是我只能变蓝不能变红,请教?急! [Re: zilin] Copy to clipboard
Posted by: floater
Posted on: 2003-03-20 23:42

zilin wrote:
我写了alert(document.bgColor);但是没有提示或显示任何信息

bgColor=#0000ff for blue
bgColor=#ff0000 for red
Like this:

function changecolor()
{
alert(document.bgColor);
if (document.bgColor == "#ff0000")
{
document.bgColor="blue";
}
else
{
document.bgColor="red";
}
...

Get a book on javascript and learn how to use alert(), it's a very useful tool for quick debugging.

6.Re:这是另外一个简单的问题,谢谢 [Re: zilin] Copy to clipboard
Posted by: why
Posted on: 2003-03-21 01:11

zilin wrote:
我认为
<%@ page import = "eoaapp.bbs.*,eoaapp.*,eoaapp.util.*,java.util.*,java.net.URLEncoder,eoaapp.filter.*"%>
和<%@ page import = "eoaapp.*,java.util.*,java.net.URLEncoder,"%>
是一样的,对吗?

No, they are different, eoaapp.bbs.*, eoaapp.util.*, etc will not be imported.

function changecolor() {
alert(document.bgColor);
if (document.bgColor == "#ff0000") {
document.bgColor="#00ff00";
}else{
document.bgColor="#ff0000";
}
}
...

7.Re:这是另外一个简单的问题,谢谢 [Re: why] Copy to clipboard
Posted by: zilin
Posted on: 2003-03-21 09:46

多谢


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923