Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a Inline Css:
XML
<style type="text/css">
    body
    {
      background-color:Black;
    }
    </style>


And A java script:
<script type="text/javascript">
function SetValue()
{
document.getElementById('HiddenField1').value = "red";
document.bgColor = document.getElementById('HiddenField1').value;
}

</script>

And I call this Java script Like

<body onload="SetValue();">


But my Problem Is,
That My Page take colour Of Style Sheet,

And If i remove Css Then My page take colour to java script,

so i want that my page contain both Css And Java Script,
and my page take colour to java script,

how can i do this
Posted

1 solution

Can you try replacing your code line with the below and see if it works
JavaScript
document.body.style.backgroundColor =  document.getElementById('HiddenField1').value;


if that doesnt work, then try using jquery like the sample below
Java
$('body').css('background', '#ccc');
 
Share this answer
 
v2
Comments
Arun kumar Gauttam 21-Jan-13 8:34am    
your first solution work well in my condition, so thanks
joe_j 21-Jan-13 9:20am    
welcome and happy coding.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900