Forum Moderators: open
As suggested in this thread [webmasterworld.com...] , I would like to use Javascript to detect the browser width and use alternative css properties for certain elements on smaller screens.
I am very much a beginner when it comes to javascript and would appreciate any help that can be leant in helping me to achieve what I want.
Thanks!
if (screen.width < 800)
document.write('<'+'link rel="stylesheet" href="http://www.domainname.com/css/smallscreen.css" />');
works well. It goes after the proper stylesheets in the head.
The smallscreen.css just has a few styles defined that overwrite the main ones, and I have a <noscript> section that also loads smallscreen.css, for those without javascript.
I'd be keen to hear if anyone knows how to do it better though.