问题
Ok, so I'm very new to Javascript and I was wondering how one goes about making the background color a variable. Specifically, I have three different frames, and I want two of the ones on the side to change their color based on which page is being visited in the third frame. How can I set the background color to for these two side frames to a variable that can be changed by whatever document is in the third frame? I've been looking around online but my search has been fruitless.
EDIT- Alternately, a way to change it by clicking on a hyperlink would work just as well for my purposes.
EDIT 2 - In the same vein as the last question, this is an alternate approach I'm trying that isn't producing much luck either, though I have more information about it: Setting background color to variable in javascript Part 2
回答1:
To manipulate the background color property with javascript you need to:
//Set to red
document.getElementById("frame").style.backgroundColor="red";
//Save into variable
var color = document.getElementById("frame").style.backgroundColor;
来源:https://stackoverflow.com/questions/4643374/setting-background-color-to-variable-in-javascript