Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Automatically reload stylesheets on HTML document (See related posts)

Code is from here and described in this great article by dc.

   1  
   2  function updateStylesheets() {
   3  	var i,a,s;
   4  	a=document.getElementsByTagName('link');
   5  	for(i=0;i<a.length;i++) {
   6  		s=a[i];
   7  		if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {
   8  			var h=s.href.replace(/(&|\\?)forceReload=d /,'');
   9  			s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf());
  10  		}
  11  	}
  12  }
  13  
  14  setInterval(updateStylesheets, 1000);

You need to create an account or log in to post comments to this site.


Click here to browse all 5337 code snippets

Related Posts