27. Implementing the advanced features of HTML 5

Using the contentEditable attribute
is used to make the text of an element as editable

<!DOCTYPE HTML>
<HTML>
<HEAD>
    <TITLE>HTML5 content editable example</TITLE>
    <SCRIPT>
        function getUserScribble()
        {
            var scribble = '<i style="color:magenta;font-family:Geneva, Arial; font-size:5;">Write here....</i>';
            document.getElementById('scribble').innerHTML = scribble;
        }
    </SCRIPT>
</HEAD>
<BODY onload="getUserScribble()">
    <P>
        <TABLE width="320" height="450" border="0" cellspacing="0" cellpadding="62">
            <TD background="np.jpg" contentEditable="true" id="scribble"></TD>
        </TABLE>
        <SCRIPT>
            getUserScribble();
        </SCRIPT>
    <P>
</BODY>
</HTML>

Implementing the spell check attribute

  1. <!DOCTYPE HTML>
  2. <HEAD>
  3. <TITLE>HTML5 spell check example</TITLE>
  4. </HEAD>
  5. <BODY>
  6. <FORM>
  7. <TEXTAREA style="width:300px;height:150px;border: 1em solid black" spellcheck="false" contentEditable="true">Spell check off</TEXTAREA><BR />
  8. <TEXTAREA style="width:300px;height:150px;border: 1em solid black" spellcheck="true" contentEditable="true">Spell check on</TEXTAREA><BR />
  9. </FORM>
  10. </BODY>
  11. </HTML>


Creating Custom Data Attributes
HTML 5 enables you to embed custom data attributes with HTML elements
the custom data attributes are prefixed with the data-text, such data-xxx and data-yyy.

  1. <!DOCTYPE HTML>
  2. <HEAD>
  3. <TITLE>HTML5 custom attributes example</TITLE>
  4. </HEAD>
  5. <BODY>
  6. <IMG src="bike3.jpg" data-out="bike5.jpg" data-over="bike4.jpg" />
  7. <IMG src="bike3.jpg" data-out="bike5.jpg" data-over="bike4.jpg" /> 
  8. <IMG src="bike3.jpg" data-out="bike5.jpg" data-over="bike4.jpg" />
  9. <SCRIPT type="text/javascript">
  10. function imagerollover(){
  11.  var allimages=document.getElementsByTagName("img")
  12.  var preloadimages=[]
  13.  for (var i=0; i<allimages.length; i++){
  14.   if (allimages[i].getAttribute("data-over"))
  15.    preloadimages.push(new Image()) 
  16.    preloadimages[preloadimages.length-1].src=allimages[i].getAttribute("data-over")
  17.    allimages[i].onmouseover=function(){
  18.     this.src=this.getAttribute("data-over")
  19.    }
  20.    allimages[i].onmouseout=function(){
  21.     this.src=this.getAttribute("data-out")
  22.    }
  23.   } 
  24.  } 
  25. }
  26. imagerollover()
  27. </SCRIPT>
  28. </BODY>
  29. </HTML>

Implementing session storage
the seessionstorage object is used to store data till the duration of the browser session.

  1. <!DOCTYPE HTML>
  2. <HEAD>
  3. <TITLE>Session storage example</TITLE>
  4. <style type="text/css"> 
  5. #todolist{  
  6.     width:350px;  
  7.     height: 200px;  
  8.     font:normal 14px Arial;  
  9.     background:lightyellow;  
  10.     border:5px groove gray;  
  11.     overflow-y:scroll;  
  12.     padding:4px;  
  13. }    
  14. #todolist ol{  
  15.     margin-left:-15px;  
  16. }    
  17. #todolist li{  
  18.     border-bottom:1px solid gray;  
  19.     margin-bottom:8px;  
  20. }
  21. </STYLE>  
  22. </HEAD>
  23. <BODY>
  24. <DIV id="todolist" contentEditable="true">  
  25. <DIV contentEditable="false"><B>Enter your tasks in the following To Do List:</B></DIV>  
  26.     <OL>  
  27.     <LI>Take breakfast in ABC hotel</LI> 
  28. <LI>Meeting with Aggrawal and group company manager</LI>     
  29.     <LI>Set alarm to 5:30 am</LI>  
  30.     </OL>  
  31. </DIV>  
  32. <INPUT type="submit" value="Reset To Do List" onClick="resetlist();return false" />   
  33. <script type="text/javascript">     

  34. var defaulthtml='<div contentEditable="false"><b>Enter your tasks in the following To Do List:</b></div>\n' 

  35. defaulthtml+='<ol>\n' 

  36. defaulthtml+='<li>Take breakfast in ABC hotel</li>\n' 

  37. defaulthtml+='<li>Meeting with Aggrawal and group company manager</li>\n' 

  38. defaulthtml+='<li>Set alarm to 5:30 am</li>\n' 

  39. defaulthtml+='</ol>' 


  40. function resetlist(){  
  41.     todolistref.innerHTML=defaulthtml  
  42.     domstorage.todolistdata=defaulthtml  
  43. }  
  44. var todolistref=document.getElementById("todolist")  
  45. var domstorage=(window.sessionStorage)? sessionStorage[location.hostname] : null 
  46. if (domstorage){  
  47.     if (domstorage.todolistdata){ 
  48.         todolistref.innerHTML=domstorage.todolistdata 
  49.     }  
  50.     todolistref.onkeyup=function(e){  
  51.         domstorage.todolistdata=this.innerHTML  
  52.     }  
  53. }  
  54. </SCRIPT> 
  55. </HTML>

Implementing local storage
local storage is same as session storage, except for the feature of persistency
local storage stores the saved data on a user's computer even after closing the browser window

  1. <!DOCTYPE HTML>
  2. <HEAD>
  3. <TITLE>HTML5 local storage example</TITLE>
  4. <style type="text/css"> 
  5. #todolist{  
  6.     width:350px;  
  7.     height: 200px;  
  8.     font:normal 14px Arial;  
  9.     background:lightyellow;  
  10.     border:5px groove gray;  
  11.     overflow-y:scroll;  
  12.     padding:4px;  
  13. }    
  14. #todolist ol{  
  15.     margin-left:-15px;  
  16. }    
  17. #todolist li{  
  18.     border-bottom:1px solid gray;  
  19.     margin-bottom:8px;  
  20. }
  21. </STYLE>  
  22. </HEAD>
  23. <BODY>
  24. <DIV id="todolist" contentEditable="true">  
  25. <DIV contentEditable="false"><B>Enter your tasks in the following To Do List:</B></DIV>  
  26.     <OL>  
  27.     <LI>Take breakfast in ABC hotel</LI> 
  28. <LI>Meeting with Aggrawal and group company manager</LI>     
  29.     <LI>Set alarm to 5:30 am</LI>  
  30.     </OL>  
  31. </DIV>  
  32. <INPUT type="submit" value="Reset To Do List" onClick="resetlist();return false" />   
  33. <script type="text/javascript">     

  34. var defaulthtml='<div contentEditable="false"><b>Enter your tasks in the following To Do List:</b></div>\n' 

  35. defaulthtml+='<ol>\n' 

  36. defaulthtml+='<li>Take breakfast in ABC hotel</li>\n' 

  37. defaulthtml+='<li>Meeting with Aggrawal and group company manager</li>\n' 

  38. defaulthtml+='<li>Set alarm to 5:30 am</li>\n' 

  39. defaulthtml+='</ol>' 


  40. function resetlist(){  
  41.     todolistref.innerHTML=defaulthtml  
  42.     domstorage.todolistdata=defaulthtml  
  43. }  
  44. var todolistref=document.getElementById("todolist")  
  45. var domstorage=window.localStorage|| (window.globalStorage? globalStorage[location.hostname] : null)  
  46. if (domstorage){  
  47.     if (domstorage.todolistdata){ 
  48.         todolistref.innerHTML=domstorage.todolistdata 
  49.     }  
  50.     todolistref.onkeyup=function(e){  
  51.         domstorage.todolistdata=this.innerHTML  
  52.     }  
  53. }  
  54. </SCRIPT> 
  55. </HTML>

Implementing Database storage
HTML 5 enables you to store your data in database on a client's machine using a real SQL database

  1. <!DOCTYPE HTML>  
  2.   <HEAD> 
  3. <TITLE> Database storage example</TITLE>
  4.  <STYLE> 
  5.             #websqldb-example .record-list li:nth-child(odd) { background-color: lightgreen; }
  6.             #websqldb-example .record-list li:nth-child(even) { background-color: pink; }
  7.             #websqldb-example .record-list li {
  8.               padding-left: 5px;
  9.             }
  10.             #db-results {
  11.               max-height: 150px;
  12.               overflow: auto;
  13.               text-align: left;
  14.             }
  15.             #websqldb-example .error {
  16.               color: red;
  17.             }
  18.           </STYLE> 
  19. </HEAD>
  20. <BODY>
  21. <DIV class="slide" id="web-sql-db"> 
  22.           <HEADER><h1>Web SQL Database</h1></HEADER> 
  23.           <SECTION> 
  24.           <DIV class="center" id="websqldb-example"> 
  25. <BUTTON onclick="webSqlSample.createTable()">create table</BUTTON> <BR />
  26.             <INPUT type="text" id="todoitem" /> 
  27.             <BUTTON onclick="webSqlSample.newRecord()">Add new item to the table</BUTTON> <BR />
  28.             <BUTTON onclick="webSqlSample.dropTable()">drop table</BUTTON> 
  29.             <P>The generated database is given as follows:</P> 
  30.             <UL class="record-list" id="db-results"></UL> 
  31.             <DIV id="db-log"></DIV> 
  32.           </DIV> 
  33.           <SCRIPT defer> 
  34.             var webSqlSample = (function() {
  35.               var db;
  36.               var log = document.getElementById('db-log');
  37.               if (window.openDatabase) {
  38.                 db = openDatabase("DBTest", "1.0", "HTML5 Database API example", 200000);
  39.                 showRecords();  
  40.               }
  41.               document.getElementById('db-results').addEventListener('click', function(e) { e.preventDefault(); }, false);
  42.                function onError(tx, error) {
  43.                 log.innerHTML = '<p class="error">Error: ' + error.message + '</p>';
  44.               }
  45.               function showRecords() {
  46.                 document.getElementById('db-results').innerHTML = '';
  47.                 db.transaction(function(tx) {
  48.                   tx.executeSql("SELECT * FROM Test", [], function(tx, result) {
  49.                     for (var i = 0, item = null; i < result.rows.length; i++) {
  50.                       item = result.rows.item(i);
  51.                       document.getElementById('db-results').innerHTML += 
  52.                           '<li><span contentEditable="true" onkeyup="webSqlSample.updateRecord('+item['id']+', this)">'+
  53.                           item['text'] + '</span> <a href="#" onclick="webSqlSample.deleteRecord('+item['id']+')">[Delete]</a></li>';
  54.                     }
  55.                   });
  56.                 });
  57.               }
  58.  
  59.               function createTable() {
  60.                 db.transaction(function(tx) {
  61.                   tx.executeSql("CREATE TABLE Test (id REAL UNIQUE, text TEXT)", [],
  62.                       function(tx) {  log.innerHTML = '<p>"Test" table created!</p>' },
  63.                       onError);
  64.                 });
  65.               }
  66.                function newRecord() {
  67.                 var num = Math.round(Math.random() * 10000); // random data
  68.                 db.transaction(function(tx) {
  69.                   tx.executeSql("INSERT INTO Test (id, text) VALUES (?, ?)", [num, document.querySelector('#todoitem').value],
  70.                       function(tx, result) {
  71.                         log.innerHTML = '';
  72.                         showRecords();
  73.                       }, 
  74.                       onError);
  75.                 });
  76.               } 
  77.               function updateRecord(id, textEl) {
  78.                 db.transaction(function(tx) {
  79.                   tx.executeSql("UPDATE Test SET text = ? WHERE id = ?", [textEl.innerHTML, id], null, onError);
  80.                 });
  81.               } 
  82.               function deleteRecord(id) {
  83.                 db.transaction(function(tx) {
  84.                   tx.executeSql("DELETE FROM Test WHERE id=?", [id],
  85.                       function(tx, result) { showRecords() }, 
  86.                       onError);
  87.                 });
  88.               } 
  89.               function dropTable() {
  90.                 db.transaction(function(tx) {
  91.                   tx.executeSql("DROP TABLE Test", [],
  92.                       function(tx) { 
  93. showRecords();
  94. log.innerHTML = '<p>Table deleted!</p>' }, 
  95.                       onError);
  96.                 });
  97.               }              
  98.               return {
  99.                 newRecord: newRecord,
  100.                 createTable: createTable,
  101.                 updateRecord: updateRecord,
  102.                 deleteRecord: deleteRecord,
  103.                 dropTable: dropTable
  104.               }
  105.             })();
  106.           </SCRIPT> 
  107.         </SECTION> 
  108.       </DIV> 
  109. </BODY>
  110. </HTML>
the createable(),
newRecord(),
deleteRecord(),
updateRecord(),
showRecord(), and dropTable() functions are created using javaScript
these functions are using the transaction() and executeSql() functions to insert and access the data stored in a database


Implementing ddrag and drop features
draggable and dropzone attributes are used to implement the drag and drop feature

  1.  <!DOCTYPE HTML>
  2. <HEAD>
  3.              <STYLE> 
  4.               #drag-zone {
  5.               list-style: none;
  6.               float: left; 
  7.             }
  8.             #drag-zone li * {
  9.               border: 4px solid #888;
  10.               display: block;
  11.             }
  12.             #drag-zone, #drop-zone, #drop-data { width: 30%; }
  13.             #drop-zone, #drop-data {
  14.               padding: 40px;
  15.               border: 5px solid #888;
  16.               float: right;
  17.               height: 200px;
  18.               overflow: auto;
  19.             }
  20.             #drop-zone.hovering {
  21.               border: 5px solid #aaa;
  22.               background-color: rgba(255, 0, 0, 0.199219);
  23.             }
  24.             #drop-data { 
  25.               background-color: #eee;
  26.               font-family: Monospace;
  27.               -ms-word-wrap: break-word;
  28.               word-wrap: break-word;
  29.             }
  30.             .datatypes {
  31.               font-weight: bold;
  32.             }
  33.             .draggable-text {
  34.               padding: 5px;
  35.             }

  36.           </STYLE> 
  37. </HEAD>
  38. <BODY>
  39.           <H1>Drag and Drop example</H1>
  40.           <SECTION id="dnd-section"> 
  41.             <OL id="drag-zone"> 
  42.               <LI><SPAN class="draggable-text" draggable>Select and drag and drop text 1</SPAN></LI> 
  43. <LI><SPAN class="draggable-text" draggable class="overwrite">Select and drag and drop text 2</SPAN></LI> 
  44. <LI><IMG src="bike3.jpg" draggable class="copy" /></LI>
  45. <LI><IMG src="bike4.jpg" draggable class="copy" /></LI> 
  46.             </OL>            
  47.            <DIV id="drop-data">Details of the dragged item</DIV> 
  48.             <DIV id="drop-zone">Drop Area</DIV> 
  49.             <SCRIPT defer> 
  50.             (function() {
  51.               var dragZone = document.querySelector('#drag-zone');
  52.               var dropZone = document.querySelector('#drop-zone');
  53.               dragZone.addEventListener('dragstart', function(event) {
  54.                 if (event.target.className) { 
  55.                   event.dataTransfer.effectAllowed = event.target.className;
  56.                   event.target.style.border = "4px solid #cc3300";
  57.                 }
  58.                 else { 
  59.                   if (event.target.parentNode.className == 'overwrite') {
  60.                     event.dataTransfer.setData("text", "<strong>Overwritten Content</strong>");
  61.                   }
  62.                   event.target.parentNode.style.border = "4px solid #cc3300";
  63.                 }
  64.                 return true;
  65.               }, true);
  66.               dragZone.addEventListener('dragend', function(event) {
  67.                 if (event.target.className) { 
  68.                   event.target.style.border = "4px solid #888";
  69.                 }
  70.                 else { 
  71.                   event.target.parentNode.style.border = "4px solid #888";
  72.                 }
  73.                 return true;
  74.               }, true);
  75.               dropZone.addEventListener('dragenter', function(event) {
  76.                 if (event.preventDefault) event.preventDefault();
  77.                 event.dataTransfer.dropEffect = 'copy';
  78.                 this.className = 'hovering';
  79.                 return false;
  80.               }, false);
  81.               dropZone.addEventListener('dragover', function(event) {
  82.                 if (event.preventDefault) event.preventDefault(); 
  83.                 event.dataTransfer.dropEffect = 'copy';
  84.                 return false;
  85.               }, false);
  86.               dropZone.addEventListener('dragleave', function(event) {
  87.                 if (event.preventDefault) event.preventDefault(); 
  88.                 this.className = '';
  89.                 return false;
  90.               }, false);
  91.               dropZone.addEventListener('drop', function(event) {
  92.                 if (event.preventDefault) event.preventDefault();
  93.                 var imgPassed = null;
  94.                 var dropdata = document.querySelector('#drop-data');
  95.                 var types = event.dataTransfer.types;
  96.                 document.querySelector('#drop-data').textContent = '';
  97.                 this.innerHTML = '';
  98.                 for (var i = 0; i < types.length; i++) {
  99.                   if (types[i] == 'Files') {
  100.                     var files = event.dataTransfer.files;
  101.                     for (var j = 0; j < files.length; j++) {
  102.                       dropdata.textContent += 'File Name: '+files[j].fileName;
  103.                       dropdata.textContent += 'File Size: '+files[j].fileSize;
  104.                     }
  105.                   }
  106.                   else {
  107.                     if (typeof event.dataTransfer.getData(types[i]) !== 'undefined') {
  108.                       dropdata.innerHTML += '<p><em class="datatypes">'+types[i]+'</em>: <br />'+event.dataTransfer.getData(types[i]).replace(/</g, '&lt;') + '</p>';
  109.                     }
  110.                   }
  111.  
  112.                   if (types[i] == 'text/uri-list') {
  113.                     imgPassed = event.dataTransfer.getData('text/uri-list');
  114.                   }
  115.                 }
  116.                 if (imgPassed) {
  117.                   var cEl = document.createElement('canvas');
  118.                   cEl.width = 200;
  119.                   cEl.height = 100;
  120.                   var ctx = cEl.getContext('2d');
  121.                   var img_buffer = document.createElement('img');
  122.                   img_buffer.src = imgPassed;
  123.                   img_buffer.style.display = 'none';
  124.                   document.body.appendChild(img_buffer); // this line only needed in safari
  125.                   img_buffer.onload = function() { ctx.drawImage(img_buffer,0,0,100,100); }
  126.                   this.appendChild(cEl);
  127.                 } else {
  128.                   if (event.dataTransfer.getData('text')) {
  129.                     this.innerHTML = event.dataTransfer.getData('text');
  130.                   }
  131.                   else if (event.dataTransfer.getData('text/plain')) {
  132.                     this.innerHTML = event.dataTransfer.getData('text/plain');
  133.                   }
  134.                 }
  135.                 return false;
  136.               }, false);
  137.             })();
  138.             </SCRIPT> 
  139.           </SECTION> 
  140.         </DIV> 
  141. </BODY>
  142. </HTML>


Implementing the geolocation feature
HTML 5 provides the support for the geolocation feature to locate a position on google maps

  1. <!DOCTYPE HTML>
  2. <HEAD>
  3. <META charset="utf-8" />
  4. <TITLE>GeoLocation Demonstrated</TITLE>
  5. </HEAD>
  6. <BODY>

  7. <SECTION id="wrapper">  
  8. <SCRIPT type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></SCRIPT>  

  9. <ARTICLE>  

  10.  <P><SPAN id="status">Please wait..we are trying to locate you...</SPAN></P>  

  11. </ARTICLE>  

  12. <SCRIPT>  

  13. function success(position) {  

  14. var s = document.querySelector('#status');    

  15. if (s.className == 'success') {  

  16.  return;  

  17. }     

  18. s.innerHTML = "found you!!!!!   Your latitude is:"+position.coords.latitude+" and longitude is:"+position.coords.longitude;

  19. s.className = 'success';    

  20. var mapcanvas = document.createElement('div');  

  21. mapcanvas.id = 'mapcanvas';  

  22. mapcanvas.style.height = '400px';  

  23. mapcanvas.style.width = '560px';   

  24. document.querySelector('article').appendChild(mapcanvas);    

  25. var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);  

  26. var myOptions = {  

  27.  zoom: 15,  

  28. center: latlng,  

  29.  mapTypeControl: false,  

  30.  navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},  

  31.  mapTypeId: google.maps.MapTypeId.ROADMAP  

  32. };  

  33. var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions);   

  34. var marker = new google.maps.Marker({  

  35.  position: latlng,  

  36. map: map,  

  37.  title:"You are here!" 

  38. });  

  39. }     

  40. function error(msg) {  

  41. var s = document.querySelector('#status');  

  42. s.innerHTML = typeof msg == 'string' ? msg : "failed";  

  43. s.className = 'fail';   

  44. // console.log(arguments);  

  45.  }     

  46. if (navigator.geolocation) {  

  47. navigator.geolocation.getCurrentPosition(success, error);  

  48. } else {  

  49.  error('not supported');  

  50.  }    

  51. </SCRIPT>  

  52. </SECTION> 

  53. </BODY>
  54. </HTML>

Implementing web worker
web workers are scripts that work in background and do not interrupt user interface scripts.

  1. <!DOCTYPE HTML>
  2. <HEAD>
  3.   <TITLE>Worker example</TITLE>
  4.  </HEAD>
  5.  <BODY style="background-color:gold;">
  6.   <H3>The highest prime number discovered so far is: <OUTPUT id="result"></OUTPUT></H3>
  7.   <SCRIPT>
  8.    var worker = new Worker('worker.js');
  9.    worker.onmessage = function (event) {
  10.      document.getElementById('result').textContent = event.data;
  11.    };
  12.   </SCRIPT>
  13.  </BODY>
  14. </HTML>

worker.js
var n = 1;
search: while (true) {
  n += 1;
  for (var i = 2; i <= Math.sqrt(n); i += 1)
    if (n % i == 0)
     continue search;
  // found a prime!
  postMessage(n);
}

Implementing notifications
HTML 5 provides desktop notifications feature that allows websites to send notifications to your desktop .
you need to run this webpage from internet information services (IIS) server
you need to copy the notification.html file in the inetpub/wwwroot folder

  1. <!DOCTYPE HTML>
  2. <HEAD> 
  3. <TITLE>HTML5 Notification Example</TITLE> 
  4. <SCRIPT> 
  5. function RequestPermission (callback) {
  6.    window.webkitNotifications.requestPermission(callback);
  7. function add(){
  8. if (window.webkitNotifications.checkPermission() > 0) {
  9.       RequestPermission(add);
  10.    }
  11.    else {
  12. var num1 = parseInt(document.getElementById('num1').value);
  13. var num2 = parseInt(document.getElementById('num2').value);
  14. var num3=num1+num2;
  15. window.webkitNotifications.createNotification("", "Sum of "+num1+" and "+num2+" is", num3).show(); 
  16. }
  17. }
  18. </SCRIPT> 
  19. </HEAD> 
  20. <BODY> 
  21. <H1>HTML5 Notification Example</H1>
  22. number 1:<INPUT type="text" id="num1" value=" " ><BR/>
  23. number 2:<INPUT type="text" id="num2" value=" " ><BR/>
  24. <BUTTON onclick="add()">add</BUTTON> 
  25. </BODY>
  26. </HTML>

Creating 2D Graphics
SVG element is used to create 2D graphics in HTML 5 

  1. <!DOCTYPE HTML>
  2. <HEAD>
  3. <TITLE>SVG</TITLE>
  4. </HEAD>
  5. <BODY>
  6. <H2>HTML5 SVG Example</H2>
  7. <SVG id="svgelem" xmlns="http://www.w3.org/2000/svg">
  8.     <CIRCLE id="redcircle" cx="50" cy="50" r="50" fill="red" />
  9. <LINE x1="200" y1="10" x2="200" y2="100"
  10.           style="stroke:purple;stroke-width:4"/>
  11. <POLYGON  points="50,100 30,20, 170,50" fill="lime" />
  12. <DEFS>
  13.       <RADIALGRADIENT id="gradient" cx="50%" cy="50%"  
  14. r="50%"
  15.       fx="50%" fy="50%">
  16.       <STOP offset="0%" style="stop-color:rgb(100,250,150);
  17.       stop-opacity:0"/>
  18.       <STOP offset="100%" style="stop-color:rgb(0,100,255);
  19.       stop-opacity:1"/>
  20.       </RADIALGRADIENT>
  21.    </DEFS>
  22.    <ELLIPSE cx="500" cy="50" rx="100" ry="50" 
  23.       style="fill:url(#gradient)" />
  24. <RECT x="50" y="50" width="250" height="250"
  25. style="fill:blue;stroke:pink;stroke-width:5;
  26. fill-opacity:0.1;stroke-opacity:0.9;padding:10,50;"/>
  27. </SVG>
  28. </HTML>

Implementing Modernizr
Modernizr helps to detect whether the browser supports CSS 3 or HTML 5 features

  1. <!DOCTYPE HTML>
  2. <HTML>
  3. <HEAD>
  4.   <meta charset="utf-8">
  5.   <TITLE>Modernizr Use</title>
  6.   <SCRIPT src="modernizr-1.6.min.js"></script>
  7. </HEAD>
  8. <BODY>
  9.  <DIV id="music">
  10.    <AUDIO>
  11.       <SOURCE src="audio.mp3" />
  12.    </AUDIO>
  13.    <BUTTON id="play">Play</button>
  14.    <BUTTON id="pause">Pause</button>
  15. </DIV>
  16.  <SCRIPT>
  17. if (Modernizr.audio) {
  18.     alert("Your Browser supports audio."); 
  19. }else{
  20.      alert("Your Browser does not support audio."); 
  21. }
  22. </SCRIPT>
  23. </BODY>
  24. </HTML>

No comments:

My Favorite Books

  • C and Data Structures by Ashok N. kamthane
  • Web Technologies by A. A. Puntambekar
  • Learn HTML and CSS with W3Schools
  • Learn JavaScript and Ajax with W3Schools
  • HTML5 Black Book: Covers Css3, Javascript,XML, XHTML, Ajax, PHP And Jquery
  • HTML5 Application Development Fundamentals: MTA Exam 98-375
  • .NET 4.0 Programming 6-In-1, Black Book
  • SQL Server 2008 R2 Black Book
  • Asp.net 4.0 Projects Covers: net 3.5 And .net 4.0 Codes, Black Book
  • UNIX Shell Programming 1 Edition by Yashavant Kanetkar
  • UNIX and Shell Programming 1 Edition by Richard F. Gilberg, Behrouz A. Forouzan
  • Computer Networks by Andrew S. Tanenbaum
  • Multiple Choice questions in computer science by Timothy J Williams