前端获得Url信息

前端获得Url信息,第1张

1、设置或获取整个 URL 为字符串

windowlocationhref

2、设置或获取 URL 的协议部分

windowlocationprotocol

3、设置或获取 URL 的主机部分

windowlocationhost

4、设置或获取与 URL 关联的端口号码

windowlocationport

5、设置或获取与 URL 的路径部分(就是文件地址

windowlocationpathname

6、设置或获取 href 属性中跟在问号后面的部分

windowlocationsearch

7、设置或获取 href 属性中在井号“#”后面的分段

windowlocationhash

码一:

<script>

function selecturl(){

z=documentbodycreateTextRange();

zmoveToElementText(selecturlDiv);

zselect();

}

</script>

<span onmousemove='selecturl()' id=selecturlDiv><script>documentwrite(locationhref)</script>

代码二:

<script>

function copyCode(o){oselect();var js=ocreateTextRange();jsexecCommand("Copy");alert("复制成功!");}

documentwrite("<table align=center class=tableborder1 cellpadding=1 cellspacing=0><tr>");

documentwrite("<td width=10% nowrap class=tablebody1>本页URL地址(双击复制):</td>");

documentwrite("<td class=tablebody1><textarea onfocus=thisselect() style='width:100%;overflow-y:visible;' ondblclick=copyCode(this) rows=1>");

documentwrite(selflocation+"</textarea></td></tr></table>");

</script>

代码三:

<script language="javascript">

<!--

function copyToClipBoard(){

var clipBoardContent=documentlocation;

clipBoardContent+='\r\n';

windowclipboardDatasetData("Text",clipBoardContent);

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

}

//-->

</script>

<script language='javascript'>

documentwrite("<img src=\"templates//images/dbgif\" width=\"49\" height=\"17\">");

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

</script>

在ASP中关于返回上一页的实现方法:

//这个大家都不陌生吧

1windowhistorygo(-1)

//若在表单中通过按钮返回上一页,则用:

2onclick="javascript:historygo(-1)"

//我最近在写程序的时候常用到这行代码!返回上一页并刷新!

3Responseredirect(requestservervariables(">

以上就是关于前端获得Url信息全部的内容,包括:前端获得Url信息、获得静态页面url地址、获取上级页面url等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9637436.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存