/    Sign up×
Community /Pin to ProfileBookmark

Javascript colour links

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:

[QUOTE]

<a href=”javascript:void(0)” target=”mainFrame” ONCLICK=”document.bgColor= ‘Yellow’ “>Yellow</a>

[/QUOTE]

to change the background colour in All the frames?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryAug 22.2003 — As this is for a school project, I won't give you the full solution, but check out the Javascript documentation for [url=http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202300]window.frames[][/url].

Adam

P.S. Good luck with the GCSEs - I just got my results through.
Copy linkTweet thisAlerts:
@bigalauthorAug 22.2003 — 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:
Copy linkTweet thisAlerts:
@AdamGundryAug 22.2003 — Ok, then I guess you want something like this (untested):
&lt;script type="text/javascript"&gt;
function setFramesColour(col){
for (i=0;i&lt;top.frames.length;i++){
top.frames[i].document.bgColor = col;
}
}
&lt;/script&gt;

&lt;a href="#" onclick="setFramesColour('yellow')"&gt;Yellow&lt;/a&gt;

Adam
Copy linkTweet thisAlerts:
@bigalauthorAug 22.2003 — Ok, ill give that a go, cheers!
Copy linkTweet thisAlerts:
@bigalauthorAug 22.2003 — YAY

That worked a treat! Your da man!

Thanks!
×

Success!

Help @bigal spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...