Finding the URL presented to the browser
<SCRIPT LANGUAGE="JavaScript"> <!-- { document.write(location.href); } // --> </SCRIPT>
11380 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
<SCRIPT LANGUAGE="JavaScript"> <!-- { document.write(location.href); } // --> </SCRIPT>
label { margin-right:10px; width:10em; float:left; }
@import "general.css";
<script type="text/javascript"> var words={ 'Bill':'William','Miss':'Mrs' } var regs=[]; for(arg in words){regs[regs.length]=new RegExp(arg,'g')} window.onload=function replaceText(){ var tags=document.getElementsByTagName('body')[0].getElementsByTagName('*'); var i=0,t; while(t=tags[i++]){ if(t.childNodes[0]){ var j=0, c; while(c=t.childNodes[j++]){ if(c.nodeType==3){ var k=0; for(arg in words){ c.nodeValue=c.nodeValue.replace(regs[k],words[arg]); k++; } } } } } }
function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") { anchor.target = "_blank"; } } } window.onload = externalLinks; ////////////// <a href="whatever" rel="external" title="whatever">Whatever</a>
<form id="search"... <a href="#" onclick="document.forms['search'].submit();return false" title="Search">Search</a>
function domRollover() { if (navigator.userAgent.match(/Opera (\S+)/)) { var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]); } if (!document.getElementById||operaVersion <7) return; var imgarr=document.getElementsByTagName('img'); var imgPreload=new Array(); var imgSrc=new Array(); var imgClass=new Array(); for (i=0;i<imgarr.length;i++){ if (imgarr[i].className.indexOf('domroll')!=-1){ imgSrc[i]=imgarr[i].getAttribute('src'); imgClass[i]=imgarr[i].className; imgPreload[i]=new Image(); if (imgClass[i].match(/domroll (\S+)/)) { imgPreload[i].src = imgClass[i].match(/domroll (\S+)/)[1] } imgarr[i].setAttribute('xsrc', imgSrc[i]); imgarr[i].onmouseover=function(){ this.setAttribute('src',this.className.match(/domroll (\S+)/)[1]) } imgarr[i].onmouseout=function(){ this.setAttribute('src',this.getAttribute('xsrc')) } } } } domRollover(); // Where your image would look like this: <img src="images/b_news.gif" alt="News" class="domroll images/b_news_roll.gif" />
x=getAttribute('src') x=x.substring(0, x.indexOf('.gif'));
if (pageName.indexOf("Text")!= -1)
function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } example = addCommas(example);