p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript (http://p2p.wrox.com/forumdisplay.php?f=85)
-   -   external CSS in JavaScript code (http://p2p.wrox.com/showthread.php?t=46945)

webdesign August 24th, 2006 06:31 PM

external CSS in JavaScript code
Is is possible to reference external style sheets in JavaScript code?
See the document.write statement below which shows the class name as dayofweek which refers to an external style sheet.

document.write('<span class="dayofweek">' + weekDay[i],"</span>");

Here is the external style sheet:
    .dayofweek {
        color: red;
        font: bold 1.25em "Times New Roman";

I don't know if the DTD is the problem or not. Below is the DTD I used which I understand forces standards mode.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     <link rel="stylesheet" type="text/css" href="external.css" />

<html xmlns="http://www.w3.org/1999/xhtml">

In my tests, using Firefox and IE 6, the style sheet is not rendered when written as an external style sheet but does work fine in both browsers when used as an embedded(internal)style sheet.
Thanks for any help.

ciwluke September 1st, 2006 04:35 PM

<link rel="stylesheet" type="text/javascript" href="external.js"/>
instead of .css replace it for javascript.

All times are GMT -4. The time now is 04:05 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.