Finding the URL presented to the browser
1 2 <SCRIPT LANGUAGE="JavaScript"> 3 4 <!-- 5 { 6 document.write(location.href); 7 } 8 // --> 9 </SCRIPT>
13393 users tagging and storing useful source code snippets
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
Alan Coleman www.alancoleman.co.uk
1 2 <SCRIPT LANGUAGE="JavaScript"> 3 4 <!-- 5 { 6 document.write(location.href); 7 } 8 // --> 9 </SCRIPT>
1 2 label { 3 margin-right:10px; 4 width:10em; 5 float:left; 6 } 7
1 2 @import "general.css";
1 2 <script type="text/javascript"> 3 var words={ 4 'Bill':'William','Miss':'Mrs' 5 } 6 var regs=[]; 7 for(arg in words){regs[regs.length]=new RegExp(arg,'g')} 8 9 window.onload=function replaceText(){ 10 var tags=document.getElementsByTagName('body')[0].getElementsByTagName('*'); 11 var i=0,t; 12 while(t=tags[i++]){ 13 if(t.childNodes[0]){ 14 var j=0, c; 15 while(c=t.childNodes[j++]){ 16 if(c.nodeType==3){ 17 var k=0; 18 for(arg in words){ 19 c.nodeValue=c.nodeValue.replace(regs[k],words[arg]); 20 k++; 21 } 22 } 23 } 24 } 25 } 26 }
1 2 function externalLinks() { 3 if (!document.getElementsByTagName) return; 4 var anchors = document.getElementsByTagName("a"); 5 for (var i=0; i<anchors.length; i++) { 6 var anchor = anchors[i]; 7 if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") { 8 anchor.target = "_blank"; 9 } 10 11 } 12 } 13 window.onload = externalLinks; 14 15 ////////////// 16 17 <a href="whatever" rel="external" title="whatever">Whatever</a> 18
1 2 <form id="search"... 3 4 <a href="#" onclick="document.forms['search'].submit();return false" title="Search">Search</a>
1 2 function domRollover() { 3 if (navigator.userAgent.match(/Opera (\S+)/)) { 4 var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]); 5 } 6 if (!document.getElementById||operaVersion <7) return; 7 var imgarr=document.getElementsByTagName('img'); 8 var imgPreload=new Array(); 9 var imgSrc=new Array(); 10 var imgClass=new Array(); 11 for (i=0;i<imgarr.length;i++){ 12 if (imgarr[i].className.indexOf('domroll')!=-1){ 13 imgSrc[i]=imgarr[i].getAttribute('src'); 14 imgClass[i]=imgarr[i].className; 15 imgPreload[i]=new Image(); 16 if (imgClass[i].match(/domroll (\S+)/)) { 17 imgPreload[i].src = imgClass[i].match(/domroll (\S+)/)[1] 18 } 19 imgarr[i].setAttribute('xsrc', imgSrc[i]); 20 imgarr[i].onmouseover=function(){ 21 this.setAttribute('src',this.className.match(/domroll (\S+)/)[1]) 22 } 23 imgarr[i].onmouseout=function(){ 24 this.setAttribute('src',this.getAttribute('xsrc')) 25 } 26 } 27 } 28 } 29 domRollover(); 30 31 // 32 33 Where your image would look like this: 34 35 <img src="images/b_news.gif" alt="News" class="domroll images/b_news_roll.gif" /> 36 37 38
1 2 x=getAttribute('src') 3 x=x.substring(0, x.indexOf('.gif'));
1 2 if (pageName.indexOf("Text")!= -1)
1 2 function addCommas(nStr) 3 { 4 nStr += ''; 5 x = nStr.split('.'); 6 x1 = x[0]; 7 x2 = x.length > 1 ? '.' + x[1] : ''; 8 var rgx = /(\d+)(\d{3})/; 9 while (rgx.test(x1)) { 10 x1 = x1.replace(rgx, '$1' + ',' + '$2'); 11 } 12 return x1 + x2; 13 } 14 15 example = addCommas(example); 16