Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

16 of 28 people (57%) answered Yes
Recently 3 of 10 people (30%) answered Yes


How do I change the bgColor of a layer in another frame with an onClick event?

Apr 4th, 2008 20:52
ha mo, Jean-Bernard Valentaten, Colin Fraser, Peter Lissenko,

> For starters you may want to have a closer look at the documentation 
> section on the front page of this language. Closer examination will 
> reveal most of the answers to you questions, however, it is also a 
> matter of looking att he jargon used, because a lot of easy answers 
> are couched in terms that are difficult to follow. 
> In a more direct response try: 
> function colorchange() {
>      parent.otherframe.document.bgColor = "red"
> }
Almost the answer *g*
Oviousely the question was how to change the bgcolor of a layer, so try 
this instead:
function colorchange() {
['theLayerUWantToChange'].document.bgColor = 'anyColorUWant';
> where otherframe.document represents the frame's document you want to 
> change the colour of. (Obviously you change the document, not the 
> frame)
> In the page try:
> <a href="javascript:void" onClick="colorchange()">Change</a>
> Good luck.