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

About this user

Oliver Haag www.ohcon.de

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Javascript Browser Check

// the navigator object stores the browser and additional secifications

   1  
   2  <html><head><title>JS Browser Check</title></head><body>
   3  
   4  <script type="text/javascript">
   5  document.write("Your browser is " + navigator.appName);
   6  
   7  if (navigator.appVersion.substring(0, 1) == "4")
   8    document.write("4th generation browser!");
   9    
  10  document.write("patform/os:" + navigator.platform);
  11  document.write("user agent data:" + navigator.userAgent);
  12  
  13  if (navigator.cookieEnabled == true) {
  14    document.write("cookies enabled");
  15  } else if (navigator.cookieEnabled == false) {
  16    document.write("no cookies.");
  17  } else {
  18    document.write("cookies? No Info available.");
  19  }
  20  
  21  if (navigator.javaEnabled()) {
  22    document.write("java enabled.");
  23  } else {
  24    document.write("java not available.");
  25  }
  26  
  27  if (navigator.language.indexOf("en") > -1) {
  28    document.write("language ins english");
  29  }else if (navigator.language.indexOf("de") > -1) {
  30    document.write("language is german");
  31  }
  32  
  33  </script>
  34  
  35  </body></html>

reformat unsigned lists (bullet lists)

// unsigned list look the same in firefox and internet explore
// but firefox uses padding and ie uses margin to indent
// so if you want to eliminate the indent you mat set both

// here the top margin is negative too
// so the bullet list is written directly under the text
// and the bottom-margin of the p-tag can remain (needet elsewhere)
   1  
   2  ul {
   3  	padding-left: 15px;
   4  	margin-left: 0px;
   5  	margin-top: -10px;
   6  	margin-bottom: 10px;
   7  }

avoid visible whitespace in html

// if you want a line break and want to indent your html code
// but the browser makes problems with the whitespace
// make the whitespace a comment

//example
   1  
   2  <div id="topimages">
   3  	<image class="left" src="image/left.jpg"><!--
   4  	--><image class="left" src="image/mid.jpg"><!--
   5  	--><image class="right" src="image/right.jpg">
   6  </div><!--topimages-->

set width and padding without ccs browser hack

// firefox an internet explorer handle padding in div-elements with width differently
// you don't need a css browser hack, you can use two div-elements insteas
// the outer-div handles width
// the inner div handles padding

//html
   1  
   2  <div id="left_text">
   3  	<div class="paddingbox">
   4  		<p>loem ipsum dolor ...</p>
   5  	</div>
   6  </div><!--left_text-->


//css
//padding: top right, bottom, left;
   1  
   2  #left_text {
   3  	width: 208px;
   4  	float: left;
   5  }
   6  div.paddingbox {
   7  	padding: 4px 8px 4px 8px;
   8  }
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS