Scripting Stylesheets
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
$(function(){ function selectStylesheetByTitle(title){ for(var i=0; i< document.styleSheets.length; i++){ var thisStylesheet = document.styleSheets[i]; var thisTitle = document.styleSheets[i].title; if(thisTitle.toLowerCase() == title.toLowerCase()){ alert('found it: '+ i); return document.styleSheets[i]; } } } //selectStylesheetByTitle('main'); /* function selectRuleBySelector(sel){ var stylesheet; if(document.styleSheets[1].cssRules){ theRules = document.styleSheets[1].cssRules; }else if(document.styleSheets[1].rules){ theRules = document.styleSheets[1].rules } for(){ } } */ var theRules = new Array(); console.log(document.styleSheets); setTimeout(function(){ console.log(document.styleSheets[0].rules[0].cssText); try{ document.styleSheets[0].rules[0].style.color = 'green'; console.log(document.styleSheets[0].rules[0].cssText); }catch(e){ alert('oop!: '+ e.message); } }, 2000); if (document.styleSheets[1].cssRules){ // Safari theRules = document.styleSheets[1].cssRules; console.log(theRules); for(var i=0; i<theRules.length; i++){ var sel = theRules[i].selectorText; // console.log(sel); if(sel.toLowerCase() == 'button'){ console.log(theRules[i].style); alert('button'); } } } else if (document.styleSheets[1].rules){ theRules = document.styleSheets[1].rules alert(2); } }); |
Detect whether or not the browser is online
https://developer.mozilla.org/en/DOM/window.navigator.onLine
Load page dynamically in jQTouch
1 2 3 4 5 6 7 8 9 10 |
// Page animations end with AJAX callback event, example 1 (load remote HTML only first time) $('#callback').bind('pageAnimationEnd', function(e, info){ if (!$(this).data('loaded')) { // Make sure the data hasn't already been loaded (we'll set 'loaded' to true a couple lines further down) $(this).append($('<div>Loading</div>'). // Append a placeholder in case the remote HTML takes its sweet time making it back load('ajax.html .info', function() { // Overwrite the "Loading" placeholder text with the remote HTML $(this).parent().data('loaded', true); // Set the 'loaded' var to true so we know not to re-load the HTML next time the #callback div animation ends })); } }); |