Skip to content

Instantly share code, notes, and snippets.

@davidhellsing
davidhellsing / support.letterspacing.js
Created January 10, 2012 13:51
Test if browser supports fractional values of letter spacing
/* Test if the browser supports decimal letterspacing for fine kerning (f.ex 0.5px)
* At the moment (january 2012), at least webkit (chrome & safari) does not render decimal pixels correctly
* https://bugs.webkit.org/show_bug.cgi?id=20606
* Using this method, you can at least provide an alternative kerning for those browsers
*/
var letterspacing = (function(d) {
var test = d.createElement('div'),
ret = true;
test.style.letterSpacing = '.5px';
@davidhellsing
davidhellsing / entity.js
Created September 12, 2011 19:51
Simple bookmarklet to convert selected text to HTML entities
function n(f) {
return f.replace(/</g,"&lt;").replace(/>/g,"&gt;");
}
a = document.activeElement;
v = a.value;
s = a.selectionStart;
e = a.selectionEnd;
a.value = v.substr(0,s) + n(v.substr(s,e)) + v.substr(e,v.length);
/*