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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading stylesheets at runtime

Status
Not open for further replies.

rotsey

Programmer
Nov 23, 2004
135
AU
Can someone point me to exmaples of how to laod a styelsheet at runtime?

I am using ASP.NET and javascript.

rotsey
 

You'd really need to ask this in the JavaScript forum.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
I just do this (ASP) in an include file
Code:
<%'  include page for the style sheets %>
<link href="/include/styles/style-main.css" rel="stylesheet" type="text/css">
<link href="/include/styles/style-include.css" rel="stylesheet" type="text/css">
<link href="/include/styles/style-nav.css" rel="stylesheet" type="text/css">
<% if styleID > 0 then
dim GroupNum
GroupNum = GetGroup(CatID)
%>
<link href="/include/styles/style-<%=GroupNum(0,0)%>.css" rel="stylesheet" type="text/css">
<%
end if
%>
the variables are set from the database and the style sheet is named accordingly.


Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 

Ah well... here's what I had anyway using JS:

Code:
<html>
<head>
	<script type="text/javascript">
	<!--
		function loadCSS() {
			var linkEl = document.createElement('link');
			document.getElementsByTagName('head')[0].appendChild(linkEl);
			linkEl.setAttribute('type', 'text/css', 0);
			linkEl.setAttribute('rel', 'stylesheet', 0);
			linkEl.setAttribute('href', 'tt01.css', 0);
		}
	//-->
	</script>
</head>

<body>
	<input type="button" value="Load style sheet" onclick="loadCSS();" />
</body>
</html>

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
cool thanks guys. I will try the javascript method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top