/    Sign up×
Community /Pin to ProfileBookmark

Using Javascript in an Embedded CSS

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 apriciated?

to post a comment
CSS

7 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisDec 05.2002 — [i]Originally posted by shutuped [/i]

[B]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?[/B][/QUOTE]


Yes. You cannot mix JS and CSS in a style sheet file.
Copy linkTweet thisAlerts:
@StefanDec 05.2002 — [i]Originally posted by shutuped [/i]

[B] I want to adjust the font sizes for different resolutions.[/QUOTE]




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 ?
Copy linkTweet thisAlerts:
@pyroDec 10.2002 — Just for the record, while you can't put JavaScript inside a .css file, you [I]can[/I] 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.
Copy linkTweet thisAlerts:
@StefanDec 10.2002 — 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. [/QUOTE]

A word of caution... with such a solution if JS is not available in the visitors browser you are **cked
Copy linkTweet thisAlerts:
@pyroDec 10.2002 — JavaScript 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.
Copy linkTweet thisAlerts:
@CharlesDec 10.2002 — [font=georgia]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.[/font]
Copy linkTweet thisAlerts:
@King_PellinoreDec 13.2002 — Yes, what Charles said is correct.

These are the stats for November 2002, available at http://www.thecounter.com/stats/2002/November/javas.php . 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.

[COLOR=sienna][SIZE=3]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%)[/SIZE]
[/COLOR]


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.
×

Success!

Help @shutuped spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...