Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Problem dynamically loading style sheet

Thread Tools

Problem dynamically loading style sheet

Hank Flowers
Posts: n/a
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:

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

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?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Page specific style style sheet ASP .Net 0 07-14-2006 03:45 PM
How to dynamically change the style sheet based on browser type Rob Roberts ASP .Net 2 01-21-2006 12:38 AM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM
FOP - Style Sheet Designer (fonts problem) enerion XML 0 04-13-2004 02:36 PM
Style sheet problem AC HTML 8 04-05-2004 06:00 PM