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!)
About this user
Yarly
Insert in place without document.write
// So, given a syndication script with a fixed ID: <script type="text/javascript" id="syndication" src="syndication.js">script> // We can go from oldskool nastiness like this: document.write('Here is some syndicated content.
'); // To modern loveliness like this: var newcontent = document.createElement('p'); newcontent.id = 'syndicated-content'; newcontent.appendChild(document.createTextNode('Here is some syndicated content.')); var scr = document.getElementById('syndication'); scr.parentNode.insertBefore(newcontent, scr); // We could even go a step further and remove the <script> ID, but in that case we would need a concrete method for identifying the specific element. We could do that by knowing its SRC: var scripts = document.getElementsByTagName('script'); for(var i=0; i<scripts.length; i++) { if(scripts[i].src == 'http://www.mydomain.com/syndication.js') { //scripts[i] is the one break; } }
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; } }); }); }