Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply styles at run time

Status
Not open for further replies.

tsisher

Programmer
Sep 14, 2004
36
GB
Is there any way of allowing the user to select from the dropdown list of font size and dropdown list of color to pick up there font size and color and the web page displays accordingly..

Thanks a lot..
 
Sure. Use CSS and a function.

To change body background, use (IE) window.document.style.backgroundColor = color;

To change font size, use (IE) window.document.style.fontSize = size.

Or, you can use window.document.setAttribute("style","background-color: " + color + "; font-size = " + size + ";");


--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
Thanks but how can I apply style sheets at run time.
 
<html>
<head>
<link rel="stylesheet" href="style1.css" type="text/css" name="styles1" id="styles1">
<script type="javascript">
function setSS()
{
var ssheet = document.styleSheets['styles1'];
ssheet.setAttribute("href","style2.css");
}
</script>
</head>
<body>
<a href="javascript:setSS();">Change the style sheet</a>
</body>
</html>

--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top