Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > values from javascript using in a stylesheet

Reply
Thread Tools

values from javascript using in a stylesheet

 
 
Madame Blablavatsky
Guest
Posts: n/a
 
      08-13-2005
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


 
Reply With Quote
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      08-13-2005
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
 
Reply With Quote
 
 
 
 
Safalra
Guest
Posts: n/a
 
      08-13-2005
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/

 
Reply With Quote
 
Madame Blablavatsky
Guest
Posts: n/a
 
      08-13-2005
> 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


 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      08-14-2005
On Sat, 13 Aug 2005 13:02:23 GMT, "Jonathan N. Little"
<(E-Mail Removed)> 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.

 
Reply With Quote
 
 
 
Reply

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
Firefox and XSLT (local stylesheet works, server-based stylesheet fails) David Blickstein XML 14 10-15-2005 11:27 PM
How to change stylesheet using Javascript? typingcat@gmail.com HTML 3 10-05-2005 09:36 PM
xml:stylesheet use in document with multiple stylesheet options David Blickstein XML 3 08-02-2005 03:10 PM
have a stylesheet generate another stylesheet based on XML? Steven An XML 1 11-23-2004 01:07 PM
Stylesheet referanse i stylesheet =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?= XML 3 07-04-2004 03:16 PM



Advertisments