Problem dynamically loading style sheet

H

Hank Flowers

In trying to load a style sheet via JavaScript I ran into a problem...the
style sheet doesn't load. This simple task has turned into a vexing problem.
Here is the script and html:

<html>
<head>
<title>load a style sheet</title>
<script type="text/javascript" language="JavaScript">
var mystyle="css/mystyle.css";
document.write=("<link rel='stylesheet' href='" + mystyle + "'
type='text/css'>");
</script>
</head>
<body>
<p class="foobar">display some text in the foobar class</p>
</body>
</html>

This is so simple it almost has to work, but it doesn't. I'm suspecting
either the browser is the problem (IE5.5) or maybe it has something to do
with being a local file or both or none of the above...dunno. Can anybody
see anything wrong here?

TIA!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top