nodster Posted July 15, 2007 Share Posted July 15, 2007 Can it be done. My website is best viewed at a high resolution, however i've had some comments that on a smaller screen/resolution i lose some of the page. now i could redo the site for the lower resolution/screen size but this would take to long. So does anyone know of a way to do this in javascript? If indeed it is possible. ??? ??? Quote Link to comment Share on other sites More sharing options...
mainewoods Posted July 15, 2007 Share Posted July 15, 2007 javascript can not change the screens resolution Quote Link to comment Share on other sites More sharing options...
xenophobia Posted July 15, 2007 Share Posted July 15, 2007 The best you can do is prompt an alert message to users that using low resolution. Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 15, 2007 Share Posted July 15, 2007 The best you can do is prompt an alert message to users that using low resolution. Second- or third-best, I'd say. Designing for any resolution (or percentage of window) is the real best solution. Quote Link to comment Share on other sites More sharing options...
nodster Posted July 16, 2007 Author Share Posted July 16, 2007 I've been thinking about this, could javascript be used to determine the size of window available and then use that answer to load a certain css file, ie so that i could use a fixed background image for each size of window or is that too difficult a way to go about it? Ta ??? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 16, 2007 Share Posted July 16, 2007 yes switch(true) { case document.body.clientWidth < 1000: // pick 1000 css. break; case document.body.clientWidth < 1300: // pick 1300 css. break; ...and so on.... } Quote Link to comment Share on other sites More sharing options...
nodster Posted July 19, 2007 Author Share Posted July 19, 2007 Ok modifying it slightly (as i don't really understand the switch function) Could somebody have a look at this code and see where i've gone wrong ??? <script language="javascript" type="text/javascript"> <!-- function checkCss() { var cssNode = document.createElement('link'); cssNode.type = 'text/css'; cssNode.rel = 'stylesheet'; cssNode.media = 'screen'; cssNode.title = 'dynamicLoadedSheet'; document.getElementsByTagName("head")[0].appendChild(cssNode); if (document.body.clientWidth < 1000); cssNode.href = 'http://website/small.css'; }else (document.body.clientWidth < 1300); cssNode.href = 'http://website/medium.css'; } </script> I have (for the time being) placed this into the <head> of my page but will be making it an external sheet was it works. TIA Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 19, 2007 Share Posted July 19, 2007 document.getElementsByTagName("head")[0].appendChild(cssNode); think you may have to change that line for var hd = document.getElementsByTagName("head"); hd[0].appendChild(cssNode); Quote Link to comment Share on other sites More sharing options...
nodster Posted July 19, 2007 Author Share Posted July 19, 2007 no joy i'm afraid. could there be another way? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.