/    Sign up×
Community /Pin to ProfileBookmark

wrapper width and screen resolution

I’m trying to set my wrapper div width so it fits to screen res. i got it working but it only works when i call it by onclick=”SetWidthToResolution()” function and i want it to load with the page.

function SetWidthToResolution()
{
if(screen.width == 2560)
{
document.getElementById(“wrapper”).style.width=”1280px”;
}
}
If i place

if(screen.width == 2560)
{
document.getElementById(“wrapper”).style.width=”1280px”;
}

in <head> it doesnt do anything

Please help, its driving me crazy

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 11.2011 — You can't reference an element until it has loaded.

Call your function onload :[CODE]window.onload=function() {
doSomething();
};[/CODE]
Copy linkTweet thisAlerts:
@jasias84authorDec 11.2011 — fonction load()

{

doSomething();

}

does the job too, is any of them faster to load or there is no difference?
Copy linkTweet thisAlerts:
@jasias84authorDec 11.2011 — fonction load()

{

doSomething();

}

does the job too, is any of them faster to load or there is no difference?[/QUOTE]


my bad, this doesn't work ?
Copy linkTweet thisAlerts:
@jasias84authorDec 11.2011 — is there anything faster?
Copy linkTweet thisAlerts:
@FangDec 12.2011 — Try loading a different css according to the [I]screen.width[/I]
Copy linkTweet thisAlerts:
@jasias84authorDec 12.2011 — can i have 2 css files? otherwise when i make any changes i will have update all css files
Copy linkTweet thisAlerts:
@007JulienDec 12.2011 — No but you can run a script witch display different css with a document.write...
Copy linkTweet thisAlerts:
@jasias84authorDec 12.2011 — i know, but updating the website would be pain in the *** if i would have to update every css file, wouldn't it?
×

Success!

Help @jasias84 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.19,
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,
)...