获得当前页面URL地址的三个JS代码
下面图老师小编要跟大家分享获得当前页面URL地址的三个JS代码,简单的过程中其实暗藏玄机,还是要细心学习,喜欢还请记得收藏哦!
script
function selecturl(){
z=document.body.createTextRange();
z.moveToElementText(selecturlDiv);
z.select();
}
/script
span onmousemove='selecturl()' id=selecturlDivscriptdocument.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=0tr");
document.write("td width=10% nowrap class=tablebody1本页URL地址(双击复制):/td");
document.write("td class=tablebody1textarea 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