/    Sign up×
Community /Pin to ProfileBookmark

Dynamic CSS resolution switcher problem.

Please bear with me I am new, tired, and have been staring at this for hours.

Now I am using this tutorial [url]http://particletree.com/features/dynamic-resolution-dependent-layouts/[/url] modified slighty to build my switcher.

I belive I have everything set correctly but unfourtnetly it refuses to work. I don’t know why. I think it is having problems picking up my style sheets although my naming conventions appear to be correct.

Heres the guts of the code. From the js file.

// dynamicLayout by Kevin Hale
function dynamicLayout(){
var browserWidth = getBrowserWidth();

//Load main1152 CSS Rules
if (browserWidth >= 1152){
changeLayout(“main1152”);
}

}

Furthermore the changeLayout function is described as:
// changeLayout is based on setActiveStyleSheet function by Paul Sowdon
// [url]http://www.alistapart.com/articles/alternate/[/url]
function changeLayout(description){
var i, a;
for(i=0; (a = document.getElementsByTagName(“link”)[i]); i++){
if(a.getAttribute(“title”) == description){a.disabled = false;}
else if(a.getAttribute(“title”) != “default”){a.disabled = true;}
}
}

And here is the code from the html

<link rel=”stylesheet” type=”text/css” href=”styles/main1024.css” title=”default”/>
<link rel=”alternate stylesheet” href=”styles/main1152.css” title=”main1152″ type=”text/css”/>

As far as I can tell it is named correctly. This is frustrating to me since I am not getting an error I am just not getting the desired result.

html: [url]http://www.havokproductions.ca/htmlport/testindex.htm[/url]
js: [url]http://www.havokproductions.ca/scripts/dynamiclayout.js[/url]
Styles:[url]http://www.havokproductions.ca/styles/main1024.css[/url]
[url]http://www.havokproductions.ca/styles/main1152.css[/url]

Any help/advice/suggestions is appreciated.
Perhaps there is an easier way to do what I desire?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorJan 26.2006 — I don't get what exactly you say it went wrong. Till than, some small CSS errors shown by my FF:

For instance, Firefox don't like:

width:89; - should be width:89[COLOR=Red]px[/COLOR];

and also it don't like:

a.link:#FFFFFF;

v.link:#FFFFFF;
Copy linkTweet thisAlerts:
@Dave_The_BMXERauthorJan 26.2006 — Yes there are a few CSS bugs I gotta weed out. The a.link/ v.link ones are gone.

Basically the js doesnt appear to be pulling the 2nd style sheet when resolutions over 1024 are used.
×

Success!

Help @Dave_The_BMXER 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.20,
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,
)...