Setting background color to variable in javascript

感情迁移 提交于 2020-01-16 18:08:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!