SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: CSS via JS

  1. #1
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS via JS

    objJournalTableRow.style.font = "italic small-caps bold 12px Comic Sans MS";


    that code in my JS file won't work, what's up?

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,426
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    It's the font name declration. You can't have spaces in font names.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    EU/UK+DK
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    stymiee is right, you need to enclose whitespace in CSS values in quotes (I have some vague memory that double-quotes are preferred, so I used them).
    Code:
    yourElement.style.font = 'italic small-caps bold 12px "Comic Sans MS"';
    That works fine in Firefox 1.5 and Internet Explorer 6, and ought to in most others.

    Off Topic:

    Of course, ideally, we'd all be keeping our styling separate from our behaviour, as well as our behaviour separate from our structure. Seeing new projects (and SitePoint articles - examples 1.1 & 1.2) which promote keeping behaviour separate from structure, and then go on to mix style and behaviour, makes me wonder why they bother.


    Regardless, I hope the code helps.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •