468,257 Members | 1,416 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,257 developers. It's quick & easy.

Modufying External stylesheet

190 100+
How can I modify external stylesheet by valuses i m getting from any oher page

<style type="text/css">
.heading {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 15px;
color: #666699;
text-decoration: none;
font-style: normal;
font-weight: bolder;
text-align: center;
}

.message {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bolder;
color: #666699;
text-decoration: none;
}


.footer {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bolder;
color: #666699;
text-decoration: none;
}
</style>


This is my stylesheet


<script language="javascript">
var mysheet=document.styleSheets[0]
var myrules=mysheet.cssRules? mysheet.cssRules[0]: mysheet.rules[0]
for (i=0; i<myrules.length; i++){
if(myrules[i].selectorText.toLowerCase()==".heading"){ //find "a:hover" rule
targetrule=myrules[i]
targetrule.style.color = "<? echo $hclr ?> "

</script>

this is the code which chages stylesheet rules

is this correct and if it is correct where should i place it so that it can be executed before the page is displayed.
Feb 9 '08 #1
1 1058
Hi,

You can modify external stylesheet ..

this script is not correct there are some small cheanges required.

<script language="javascript">
var mysheet=document.styleSheets[0]
var myrules=mysheet.cssRules? mysheet.cssRules[0]: mysheet.rules[0]
[SA] Change this lines if u want to used array then why are u used the CSS first element take all the element
var myrules=mysheet.cssRules? mysheet.cssRules: mysheet.rules


and every thing is all right if u want to executed before the page is displayed used in head elemnt show this is display before execution or may be used on onload event of the body..

Regards,
Sandeep Agarwal
Feb 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by allard poldermans | last post: by
reply views Thread by Shawn Modersohn | last post: by
12 posts views Thread by Peter Collinson | last post: by
6 posts views Thread by Christopher Benson-Manica | last post: by
2 posts views Thread by Markus Ernst | last post: by
26 posts views Thread by HarryO | last post: by
6 posts views Thread by Stephen Cook | last post: by
7 posts views Thread by Dan Nash | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.