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

IE doesn't support element.setAttritube('style') (See related posts)

   1  
   2  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
   3  <html xmlns="http://www.w3.org/1999/xhtml" version="-//W3C//DTD XHTML 1.1//EN" xml:lang="fr">
   4  <head>
   5  
   6  <title>.setAttribute('style','');</title>
   7  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   8  
   9  <script type="text/javascript">
  10  <!--
  11  
  12  window.onload = function() {
  13  	if (navigator.appName == 'Microsoft Internet Explorer') {
  14  		document.getElementById('test').style.cssText = 'background:gray; color:white;';
  15  	} else {
  16  		/* document.getElementById('test').style.cssText = 'background:gray; color:white;'; */
  17  		document.getElementById('test').setAttribute('style', 'background:gray; color:white;');
  18  	}
  19  }
  20  
  21  -->
  22  </script>
  23  
  24  </head>
  25  
  26  <body>
  27  
  28  <div id="test">document.getElementById('test').setAttribute('style', 'background:gray; color:white;')</div>
  29  
  30  </body>
  31  
  32  </html>

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


Click here to browse all 5545 code snippets

Related Posts