Javascript: changing background color

Ok so this is what i have to create (its from a tutorial) :slight_smile:

http://hotwired.lycos.com/webmonkey/98/03/homework3a/homework.html

But i can’t seem to get it to work? I tried view source but it doesn’t tell me the source for the other pages, only for the main page which holds all the sub-pages.

I have tried:


<a href="#" onClick="top.frame2.document.body.bgcolor='red';">Red</a>

Shouldn’t that do the job for changing the background color to red? thanks!!


<A href="#" onclick="document.body.style.backgroundColor = '#ff0000';">red</a>

unless you want the page to automatically scroll back to the top i’d use ‘javascript: void(0);’ instead of ‘#’

btw for things like this i’d check msdn first: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods.asp

oh ok thanks, because the tutorial told me to do “#”, but i have no clue what it does :stuck_out_tongue: Btw, don’t i need to target the frame i want the color to change in? so would it be:

frame2.document.body…

thanks!

*Originally posted by blah-de-blah *
**oh ok thanks, because the tutorial told me to do “#”, but i have no clue what it does :stuck_out_tongue: Btw, don’t i need to target the frame i want the color to change in? so would it be:

frame2.document.body…

thanks! **

I’m pretty sure that’s the notation,

and btw in the previous post it says ‘about’, but it’s supposed to say: javascript

ah yea its working, i just hadta add top.frame2 to the code, so i could target another frame. Thanks!

If you want the source then just right-click on the area where u think the frame is and say view source.

ahh thats how you do it, thx for the tip :wink: