获得本页面URL地址的三个JS代码

发表于:2007-06-21来源:作者:点击数: 标签:
代码一: script function selecturl(){ z=document.body.createTextRange(); z.moveToElementText(selecturlDiv); z.select(); } /script span onmousemove='selecturl()' id=selecturlDivscriptdocument.write(location.href)/script 代码二: script func

   
  代码一:

<script>
function selecturl(){
z=document.body.createTextRange();
z.moveToElementText(selecturlDiv);
z.select();
}
</script>

<span onmousemove='selecturl()' id=selecturlDiv><script>document.write(location.href)</script>

代码二:

<script>
function copyCode(o){o.select();var js=o.createTextRange();js.execCommand("Copy");alert("复制成功!");}
document.write("<table align=center class=tableborder1 cellpadding=1 cellspacing=0><tr>");
document.write("<td width=10% nowrap class=tablebody1>本页URL地址(双击复制):</td>");
document.write("<td class=tablebody1><textarea onfocus=this.select() style='width:100%;overflow-y:visible;' ondblclick=copyCode(this) rows=1>");
document.write(self.location+"</textarea></td></tr></table>");
</script>

代码三:

<script language="javascript">

<!--

function copyToClipBoard(){

var clipBoardContent=document.location;

clipBoardContent+='rn';

window.clipboardData.setData("Text",clipBoardContent);

alert("耶!复制成功喽!你可以粘贴在QQ消息里送给你的好朋友呀!再次感谢你对 {TheBlogTitle} 的支持哦!");

}

//-->

</script>

<script language='javascript'>

document.write("<img src="templates/{TemplateName}/images/db.gif" width="49" height="17">");

document.write("<input size="60" value=""+document.location+""><input type="button" value="推荐给朋友" title="点击复制地址到剪贴板,直接在MSN/QQ上粘贴即可." onclick="copyToClipBoard()">");

</script>

原文转自:http://www.ltesting.net