Never been to TextSnippets 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 (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Safari

if (navigator.userAgent.indexOf('Safari') != -1) {
        window.addEventListener('load', function() {
                var lock = false;
                var labels = document.getElementsByTagName('label');
                for (var i = 0; i < labels.length; i++)
                        labels[i].addEventListener('click', function() {
                                var input = (this.htmlFor ? document.getElementById(this.htmlFor) : this.getElementsByTagName('input')[0]);
                                if (input && !lock) {
                                        input.focus();
                                        lock = true;
                                        input.click();
                                        lock = false;
                                }
                        });
        });
}
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed