Difference between revisions of "Title Attribute Favlet"

From Level Access Web Labs
Jump to navigation Jump to search
Line 1: Line 1:
 
This Favlet displays the text of all title attributes.
 
This Favlet displays the text of all title attributes.
<html>
+
 
 
<a href=”javascript:(function(){var%20element=document.createElement(‘script’);element.setAttribute(‘src’,'Title attribute.js’);document.body.appendChild(element);})();”> Title Attribute Favlet </a>
 
<a href=”javascript:(function(){var%20element=document.createElement(‘script’);element.setAttribute(‘src’,'Title attribute.js’);document.body.appendChild(element);})();”> Title Attribute Favlet </a>
  
</html>
 
 
<h2> Sample code </h2>
 
<h2> Sample code </h2>
 
<code>
 
<code>

Revision as of 02:51, 5 February 2014

This Favlet displays the text of all title attributes.

<a href=”javascript:(function(){var%20element=document.createElement(‘script’);element.setAttribute(‘src’,'Title attribute.js’);document.body.appendChild(element);})();”> Title Attribute Favlet </a>

Sample code

javascript:(function(){
var el = document.querySelectorAll('[title]');
var str;
var headers=[];
var sentinel;
if (el.length>0) {
 	for (var i=0; i<el.length; i++) {
			s = document.createElement('Span');
			t = document.createTextNode(" Title="+el.item(i).title +" ");
			s.appendChild(t);
			s.style.backgroundColor = 'antiqueWhite';
			s.style.color = 'black';
			el.item(i).parentNode.insertBefore(s,el.item(i));
	}
}
else {
	  alert('no elements with titles');
}

})();