By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,785 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,785 IT Pros & Developers. It's quick & easy.

Modufying External stylesheet

100+
P: 190
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
Share this Question
Share on Google+
1 Reply


P: 50
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.