Click to See Complete Forum and Search --> : Javascript colour links
bigal
08-22-2003, 04:07 AM
I am making a website for gcse and it has a frame at the top and a main frame, the frame at the top has text links to change the colour of the background in the frame below, how do you tell this:
<a href="javascript:void(0)" target="mainFrame" ONCLICK="document.bgColor= 'Yellow' ">Yellow</a>
to change the background colour in All the frames?
AdamGundry
08-22-2003, 05:06 AM
As this is for a school project, I won't give you the full solution, but check out the Javascript documentation for window.frames[] (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202300).
Adam
P.S. Good luck with the GCSEs - I just got my results through.
bigal
08-22-2003, 05:12 AM
no, please give me the full answer, i have been searching since 7:00 this morning, and its now 11:00!
And i havn't been set this task, ime just doing something i will add to my corsework (ime in yr9 going into Yr10!)
Oh, yeah and i Want it to Change the Background in ALL the Frames in the page, not just the one with the link in! :rolleyes:
AdamGundry
08-22-2003, 05:49 AM
Ok, then I guess you want something like this (untested):
<script type="text/javascript">
function setFramesColour(col){
for (i=0;i<top.frames.length;i++){
top.frames[i].document.bgColor = col;
}
}
</script>
<a href="#" onclick="setFramesColour('yellow')">Yellow</a>
Adam
bigal
08-22-2003, 06:49 AM
Ok, ill give that a go, cheers!
bigal
08-22-2003, 06:54 AM
YAY
That worked a treat! Your da man!
Thanks!