Hi All, Is there any advantage to testing the availability of styling before running scripts?
The scenario I'm thinking of is JS available but no CSS, either unavailable or switched off. Something like: var cssOn; var gotStyle=function(){ function init(){ // Simon Willisons - http://simonwillison.net/2004/May/26/addLoadEvent/ function addLoadEvent(f){var o=window.onload;if(typeof window.onload!='function'){window.onload=f;}else{window.onload=function(){if(o){o();}f();};}} // mike foskett - http://websemantics.co.uk/resources/useful_javascript_functions/ function hasCSS(){var d=document.createElement('div');d.id="hasCSS";document.body.appendChild(d);var o=document.getElementById("hasCSS"),v=false;if(window.getComputedStyle){v=(window.getComputedStyle(o,null).getPropertyValue('display')==='none');}else{if(o.currentStyle){v=(o.currentStyle.display==='none');}}document.body.removeChild(d);return v;} addLoadEvent(function(){ cssOn=hasCSS(); }); } return{ init:init }; }(); gotStyle.init(); In the CSS: #hasCSS {display:none} The above: 1. waits for page load 2. appends a test element 3. applies a style to it 4. tests for the applied style 5. sets the global variable accordingly 6. removes the test element Regards, Mike ________________________________ This is a confidential email. Tesco may monitor and record all emails. The views expressed in this email are those of the sender and not Tesco. Tesco Stores Limited Company Number: 519500 Registered in England Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire EN8 9SL VAT Registration Number: GB 220 4302 31 ******************************************************************* List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: memberh...@webstandardsgroup.org *******************************************************************