Difference between revisions of "Lang Favlet"

From Level Access Web Labs
Jump to navigation Jump to search
Line 4: Line 4:
 
<a href="javascript:(function(){var%20element=document.createElement('script');element.setAttribute('src','lang.js');document.body.appendChild(element);})();"> lang attributes Favlet </a>
 
<a href="javascript:(function(){var%20element=document.createElement('script');element.setAttribute('src','lang.js');document.body.appendChild(element);})();"> lang attributes Favlet </a>
 
</html>
 
</html>
 +
Sample code
 +
<code>
 +
<pre>
 +
javascript:(function(){
 +
var el = document.querySelectorAll('[lang]');
 +
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(" lang="+el.item(i).lang +" ");
 +
s.appendChild(t);
 +
s.style.backgroundColor = 'antiqueWhite';
 +
s.style.color = 'black';
 +
el.item(i).insertBefore(s,el.item(i).firstChild);
 +
}
 +
}
 +
else {
 +
  alert('no language set');
 +
}
  
 +
})();
 +
</pre>
 +
</code>
 
[[Category:Favlet]]
 
[[Category:Favlet]]

Revision as of 02:25, 5 February 2014

This Favlet uses the direct link technique and is too long to run in IE. lang attributes Favlet Sample code

javascript:(function(){
var el = document.querySelectorAll('[lang]');
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(" lang="+el.item(i).lang +" ");
			s.appendChild(t);
			s.style.backgroundColor = 'antiqueWhite';
			s.style.color = 'black';
			el.item(i).insertBefore(s,el.item(i).firstChild);
	}
}
else {
	  alert('no language set');
}

})();