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

CSS loading

Status
Not open for further replies.

VJar

Programmer
Aug 3, 2002
18
UA
Is it impossible to load css style (css-file)
for html document? Write example please.
 
What do you mean by "load"?? I have not failed; I merely found 100,000 different ways of not succeding...
 
this is a long shot with not a very specific question, but do you mean just a external css file to load the format etc. when the page loads??????

<link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot;> You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
I need to load css-file (<link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot;> ) but in body of Java Script. How can I make so?
 
You have to use document.write():

<script>
document.write('<link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot;>')
</script>


If you need to add an aproppriate style according some condition, here's how to do it:

function condition() {

if (value==1)
css='style1.css'

else
if (value==2)
css='style2.css';

return(css);
}

function addStyle() {

document.write('<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;' + condition() + '&quot;>');
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top