I have been using an Embedded style sheet in a large number of pages on my site. I want to adjust the font sizes for different resolutions. I know I can use javascript to load different style sheets dependent upon screen res. but if I do that I will have to go through every single file that loads my embeded style sheet and add the javascript.
Is it posible to use a few lines of javascript within the style sheet to use different settings for different screen res? or do I just have to make another style sheet for each different res. and put that small bit of javascript into all of my pages?
any ideas would be apriciatedOriginally posted by shutuped
do I just have to make another style sheet for each different res. and put that small bit of javascript into all of my pages?
Yes. You cannot mix JS and CSS in a style sheet file.Originally posted by shutuped
I want to adjust the font sizes for different resolutions.
Why not just leave that up to the user?
I'm sure they are perfectly capable of setting a screen resolution and default fontsize that works just fine for them Just for the record, while you can't put JavaScript inside a .css file, you can put CSS in a .js file. I know it doesn't really help you, as you would have to change all your .css links to a .js link, but I thought I'd let you know. If you need an example of how this is done, let me know.I know it doesn't really help you, as you would have to change all your .css links to a .js link, but I thought I'd let you know.
A word of caution... with such a solution if JS is not available in the visitors browser you are **ckedJavaScript is popular enough that I don't see this as a problem. You could add a simple script that lets people know that they need a JavaScript enabled browser. I doubt many people are using browsers that are old enough to warrent not using this meathod. The only problem that I would forsee is people who have JavaScript turned off. But, you could also redirect them to a page telling them they need to turn it on. I suppose if you are designing so that everyone can see it, you should never use JavaScript. Correct me if I'm wrong on this...because I'm thinking about making the navigation (and actually the viewing) of a site totally dependent on the fact the enough people have JavaScript to do this.Just for the record, the last number I saw cited 12% as the precentage of internet users who do not use JavaScript. That's a huge number of people and I'm one of them. Some people turn it off because much of what bad web authors do with JavaScript makes the page inaccessible to persons with their disabilities. I turn it off because bad web authors keep making their pages annoying.Yes, what Charles said is correct.
These are the stats for November 2002, available at <!-- m --><a class="postlink" href="http://www.thecounter.com/stats/2002/November/javas.php">http://www.thecounter.com/stats/2002/November/javas.php</a><!-- m --> . The Counter is used as a fairly reliable statistics logger, because it monitors several hundred million hits per month, more than enough to sample an environment.
JavaScript Stats
Fri Nov 1 00:05:01 2002 - Sat Nov 30 23:55:05 2002 30.0 Days
Javascript 1.2+: 309600823 (88%)
Javascript <1.2: 848682 (0%)
Javascript false: 38101069 (10%)
I don't know where the other 2% are gone, I didn't write this. But see the numbers of hits for yourselves.
Why? Many people browse from schools and universities, which don't enable JavaScript.
Others believe "good advice" from losers. For example, Reader's Digest published something like this in a heavily-advertised useless computer manual ("How to manage your finances using a spreadsheet"-type of thing):
"Hints and tips: Java and JavaScript are used in web pages to create flashing titles and animated text. Follow these simple steps to disable those polluters and save your eyesight!"
That nearly made me cry.
Is it posible to use a few lines of javascript within the style sheet to use different settings for different screen res? or do I just have to make another style sheet for each different res. and put that small bit of javascript into all of my pages?
any ideas would be apriciatedOriginally posted by shutuped
do I just have to make another style sheet for each different res. and put that small bit of javascript into all of my pages?
Yes. You cannot mix JS and CSS in a style sheet file.Originally posted by shutuped
I want to adjust the font sizes for different resolutions.
Why not just leave that up to the user?
I'm sure they are perfectly capable of setting a screen resolution and default fontsize that works just fine for them Just for the record, while you can't put JavaScript inside a .css file, you can put CSS in a .js file. I know it doesn't really help you, as you would have to change all your .css links to a .js link, but I thought I'd let you know. If you need an example of how this is done, let me know.I know it doesn't really help you, as you would have to change all your .css links to a .js link, but I thought I'd let you know.
A word of caution... with such a solution if JS is not available in the visitors browser you are **ckedJavaScript is popular enough that I don't see this as a problem. You could add a simple script that lets people know that they need a JavaScript enabled browser. I doubt many people are using browsers that are old enough to warrent not using this meathod. The only problem that I would forsee is people who have JavaScript turned off. But, you could also redirect them to a page telling them they need to turn it on. I suppose if you are designing so that everyone can see it, you should never use JavaScript. Correct me if I'm wrong on this...because I'm thinking about making the navigation (and actually the viewing) of a site totally dependent on the fact the enough people have JavaScript to do this.Just for the record, the last number I saw cited 12% as the precentage of internet users who do not use JavaScript. That's a huge number of people and I'm one of them. Some people turn it off because much of what bad web authors do with JavaScript makes the page inaccessible to persons with their disabilities. I turn it off because bad web authors keep making their pages annoying.Yes, what Charles said is correct.
These are the stats for November 2002, available at <!-- m --><a class="postlink" href="http://www.thecounter.com/stats/2002/November/javas.php">http://www.thecounter.com/stats/2002/November/javas.php</a><!-- m --> . The Counter is used as a fairly reliable statistics logger, because it monitors several hundred million hits per month, more than enough to sample an environment.
JavaScript Stats
Fri Nov 1 00:05:01 2002 - Sat Nov 30 23:55:05 2002 30.0 Days
Javascript 1.2+: 309600823 (88%)
Javascript <1.2: 848682 (0%)
Javascript false: 38101069 (10%)
I don't know where the other 2% are gone, I didn't write this. But see the numbers of hits for yourselves.
Why? Many people browse from schools and universities, which don't enable JavaScript.
Others believe "good advice" from losers. For example, Reader's Digest published something like this in a heavily-advertised useless computer manual ("How to manage your finances using a spreadsheet"-type of thing):
"Hints and tips: Java and JavaScript are used in web pages to create flashing titles and animated text. Follow these simple steps to disable those polluters and save your eyesight!"
That nearly made me cry.