values from javascript using in a stylesheet

Discussion in 'HTML' started by Madame Blablavatsky, Aug 13, 2005.

  1. hello,

    i have tables and layers in a stylesheet.
    the window people use can have a different width and height.

    i want to change the width and height of the tables/layers in the stylesheet
    depending on the
    window width and height of the user.

    i know how to get the height and width of the window using javascript, but i
    do not know
    how to get these values in the stylesheet.

    so my question is: how do i get the values from javascript into the
    stylesheet?


    thanks
     
    Madame Blablavatsky, Aug 13, 2005
    #1
    1. Advertising

  2. Madame Blablavatsky wrote:
    > hello,
    >
    > i have tables and layers in a stylesheet.
    > the window people use can have a different width and height.
    >
    > i want to change the width and height of the tables/layers in the stylesheet
    > depending on the
    > window width and height of the user.
    >
    > i know how to get the height and width of the window using javascript, but i
    > do not know
    > how to get these values in the stylesheet.
    >
    > so my question is: how do i get the values from javascript into the
    > stylesheet?

    You cannot plug in the JavaScript variable values into a stylesheet
    AFAIK, but you could use JavaScript to change an element's style
    attributes on the fly to do basically the same thing.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Aug 13, 2005
    #2
    1. Advertising

  3. Madame Blablavatsky

    Safalra Guest

    Madame Blablavatsky wrote:
    > i have tables and layers in a stylesheet.
    > the window people use can have a different width and height.
    > i want to change the width and height of the tables/layers in the stylesheet
    > depending on the
    > window width and height of the user.
    > i know how to get the height and width of the window using javascript, but i
    > do not know
    > how to get these values in the stylesheet.


    Seeing as you don't mind being dependent on Javascript, you can alter
    the styling of an element through Javascript. Give the element an id
    and then use something of the form:

    document.getElementById('elementID').style.width=(windowwidth-200)+'px';

    Here 'elementID' is the ID you've given the element, and 'windowwidth'
    is a variable in which you've put the size of the window. You'll want
    to use pixel units as the window size is measured in pixels.

    Note however, that it's a really bad idea to make your page dependent
    on Javascript, and dynamic resizing can be done through a combination
    of 'fluid layout' and well-written stylesheets. Start here if you want
    to know more:

    http://allmyfaqs.com/faq.pl?AnySizeDesign

    --
    Safalra (Stephen Morley)
    http://www.safalra.com/programming/javascript/
     
    Safalra, Aug 13, 2005
    #3
  4. > Note however, that it's a really bad idea to make your page dependent
    > on Javascript, and dynamic resizing can be done through a combination
    > of 'fluid layout' and well-written stylesheets. Start here if you want
    > to know more:
    >
    > http://allmyfaqs.com/faq.pl?AnySizeDesign



    well, normaly i am programming in php, but now i have to help an
    inexperienced designer making a site look good for different resolutions
    (800/600 ; 1024 and so on).

    i have no experience in doing this so i thought of finding the
    windowsize/resolution and using this to set the width/height/top/left etc of
    the stylesheet for the objects on the page.

    i don't have to use javascript to do this, it is that i just don't know the
    best way of doing it.

    thanks for your link, it looks interesting
     
    Madame Blablavatsky, Aug 13, 2005
    #4
  5. Madame Blablavatsky

    Andy Dingley Guest

    On Sat, 13 Aug 2005 13:02:23 GMT, "Jonathan N. Little"
    <> wrote:

    >you could use JavaScript to change an element's style
    >attributes on the fly to do basically the same thing.


    A nit-pick:

    You can use JavaScript to change the element's style _properties_ on the
    fly.

    If you try changing _attributes_ as if you were re-writing the HTML
    source, then it will have no effect.
     
    Andy Dingley, Aug 14, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    65,649
    =?ISO-8859-1?Q?G=E9rard_Talbot?=
    Oct 5, 2005
  2. =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

    Stylesheet referanse i stylesheet

    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=, Jul 3, 2004, in forum: XML
    Replies:
    3
    Views:
    578
    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=
    Jul 4, 2004
  3. Steven An
    Replies:
    1
    Views:
    504
    Martin Honnen
    Nov 23, 2004
  4. David Blickstein
    Replies:
    3
    Views:
    1,039
    David Blickstein
    Aug 2, 2005
  5. David Blickstein
    Replies:
    14
    Views:
    6,343
    Harrie
    Oct 16, 2005
Loading...

Share This Page