/    Sign up×
Community /Pin to ProfileBookmark

help on auto change CSS base on user’s resolution..

I found a script a javascript.internet.com:

[CODE]

<script type=”text/javascript”>
if (screen.width < 1024)
link = document.getElementsByTagName(“link”)[0];
link.href = “size800.css”;
</script>

[/CODE]

Here’s the source [url]http://javascript.internet.com/css/style-sheets-by-resolution-3.html[/url]

but it doesnt seem to work, i placed it in my header, and i have created a CSS for it. But it doesn’t load when I adjusted my screen resolution.

Did I miss something? or is there something wrong with the code? need help i’m a javascript newbie ?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@jehzlauauthorApr 05.2007 — huhuhu i hope somebody will reply to this post ?
Copy linkTweet thisAlerts:
@jehzlauauthorApr 05.2007 — hoping that someone out there will reply in my post ?
Copy linkTweet thisAlerts:
@equazcionApr 05.2007 — I don't think you can get javascript to fire off when you change your screen resolution. How many users are going to be changing their resolutions while they're at your site? Generally, the point of resolution detection is just to get your site to look the same no matter what resolution the users' screens are ALREADY set at.

I don't know offhand if the code you posted would work, but to test it I would try changing your screen resolution and THEN loading the page to see how it looks. Then close your browser, change the resolution again, and reload the page to see how it looks again in the new resolution.

It's highly unlikely that anyone will change their screen resolutions while looking at your page, so it's silly to prepare for that, not to mention I'm pretty sure it's impossible.
Copy linkTweet thisAlerts:
@jehzlauauthorApr 06.2007 — i have found an answer to my question. ?

Like yahoo.com, if you view it in 800x600, the design changes. Mine too ?

I made a javascript function the redirects to a new index with different CSS and resized images ? weeeeeee!!
×

Success!

Help @jehzlau 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.28,
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,
)...