sunicani Posted July 11, 2009 Share Posted July 11, 2009 <script type="text/javascript" language="javascript">var Swidth=screen.width;var Surl="http://www.xxxbuy.com/";var Skin=["common.css","home.css"];var Skintemp;if (Swidth>=1280){Surl+="skin_1200";}else{Surl+="Skin";}for (var i=0;i<skin.length;i++){Skintemp=document.creatElement("link");Skintemp.type="text/css";Skintemp.rel="stylesheet";Skintemp.href=Srul+"/"+Skin;document.getElementByTagName("head")[0].appendChild(Skintemp);}</script><noscript><link type="text/css" rel="stylesheet" href="http://www.360buy.com/skin/common.css"/><link type="text/css" rel="stylesheet" href="http://www.360buy.com/skin/home.css"/></noscript>as we can see from above that a kind of 'for' function combined with CSS was used to adjust page format. and, I really don't know what's the function of 'document.creatElement("link"), does it means a Link can be produced? for page format like 'common.css' and 'home.css'?any experts who can interpret this for me??thanks a lot Link to comment Share on other sites More sharing options...
Ingolme Posted July 11, 2009 Share Posted July 11, 2009 The createElement() method is explained in the W3Schools XML DOM tutorialI don't recommend loading stylesheets based on screen width, some people may have Javascript disabled. You should design sites to be flexible instead. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.