quint
05-11-2007, 06:00 AM
I was messing around and wrote this little script (below). I thought what it would do is onclick write "Hello World!" beneath the links, but it is overwriting the links themselves.
Can someone please explain what I would have to do to get it to write "Hello World!" beneath the links and in the color selected onclick?
Thanks,
~q
---------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function message(color){
if (color == 'r')
{
document.write("<P><h2><font color=red>Hello World!</font></h2>")
}
else if (color == 'g')
{
document.write("<P><h2><font color=green>Hello World!</font></h2>")
}
if (color == 'b')
{
document.write("<P><h2><font color=blue>Hello World!</font></h2>")
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000"><p>
<a href="javascript:message('r')">Red</a> <a href="javascript:message('g')">Green</a>
<a href="javascript:message('b')">Blue </a> </p>
<P>
<script type="text/javascript">
function message(color){ }
</script>
</body>
</html>
Can someone please explain what I would have to do to get it to write "Hello World!" beneath the links and in the color selected onclick?
Thanks,
~q
---------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function message(color){
if (color == 'r')
{
document.write("<P><h2><font color=red>Hello World!</font></h2>")
}
else if (color == 'g')
{
document.write("<P><h2><font color=green>Hello World!</font></h2>")
}
if (color == 'b')
{
document.write("<P><h2><font color=blue>Hello World!</font></h2>")
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000"><p>
<a href="javascript:message('r')">Red</a> <a href="javascript:message('g')">Green</a>
<a href="javascript:message('b')">Blue </a> </p>
<P>
<script type="text/javascript">
function message(color){ }
</script>
</body>
</html>