function urlencode(strText) { var isObj; var trimReg; if(typeof(strText) == "string") { if( strText != null ) { trimReg = /(^\s+)|(\s+$)/g; strText = strText.replace( trimReg, ''); for(i=32;i<256;i++) { strText = strText.replace(String.fromCharCode(i),escape(String.fromCharCode(i))); } } } else { alert(typeof(strText)); } return strText; } Ref = urlencode(document.referrer); Url = urlencode(window.location.href); document.write("");