获取当前地址,JS获取当前URL:
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<SCRIPT>
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;
strwrite = "<tr><td valign=top>thisURL: </td><td>[" + thisURL + "]</td></tr>"
strwrite += "<tr><td valign=top>thisHREF: </td><td>[" + thisHREF + "]</td></tr>"
strwrite += "<tr><td valign=top>thisSLoc: </td><td>[" + thisSLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisDLoc: </td><td>[" + thisDLoc + "]</td></tr>"
document.write( strwrite );
</SCRIPT>
thisDLoc = document.location; <BR>thisURL = document.URL; <BR>thisHREF = document.location.href; <BR>thisSLoc = self.location.href;<BR>
<SCRIPT>
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
strwrite = "<tr><td valign=top>thisTLoc: </td><td>[" + thisTLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisPLoc: </td><td>[" + thisPLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisTHost: </td><td>[" + thisTHost + "]</td></tr>"
strwrite += "<tr><td valign=top>thisHost: </td><td>[" + thisHost + "]</td></tr>"
document.write( strwrite );
</SCRIPT>
thisTLoc = top.location.href; <BR>thisPLoc = parent.document.location; <BR>thisTHost = top.location.hostname; <BR>thisHost = location.hostname;<BR>下面这个函数我看了,是可以获取当前URL的文件名的
<SCRIPT>
tmpHPage = thisHREF.split( "/" );
thisHPage = tmpHPage[ tmpHPage.length-1 ];
tmpUPage = thisURL.split( "/" );
thisUPage = tmpUPage[ tmpUPage.length-1 ];
strwrite = "<tr><td valign=top>thisHPage: </td><td>[" + thisHPage + "]</td></tr>"
strwrite += "<tr><td valign=top>thisUPage: </td><td>[" + thisUPage + "]</td></tr>"
document.write( strwrite );
</SCRIPT>
<TBODY>
<TR>
<TD></TR></TBODY></TABLE>
原文来自:
分享到:
相关推荐
如何用js获取当前url的参数值 如何用js获取当前url的参数值
主要用到Location 对象,包含有关当前 URL 的信息,是 Window 对象的一个部分,可通过 [removed] 属性来访问。 方法一、js获取项目根路径的方法 function getRootPath(){ var curPageUrl = [removed].href; var ...
C#获取当前页面的url 和JavaScript 获取当前页面的URL
具体代码如下所示: /* 定义替换对象键值 */ var setReferArgs = function(){ var referArgs = new ...var replaceUrlParams = function(url){ var actualUrl = ""; var referArgs = setReferArgs(); for(var ke
本篇文章主要是对js获取当前地址 JS获取当前URL的示例代码进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助
JS 获取当前页面 URL.docx
这篇文章主要介绍了JavaScript获取当前url路径过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 1、假设当前页完整地址是:...
NULL 博文链接:https://onestopweb.iteye.com/blog/2292540
获得当前页面的url window.location.herf window.location.href location.search; //获取url中"?"符后的字串 document.referrer 获取来路的url,相当于php的$_SERVER['HTTP_REFERER']。 encodeURIComponent()...
js 获取当前网页 1.获取当前完整网址 <script type="text/javascript"> thisURL = document.URL; thisHREF = document.location.href; thisSLoc = self.location.href; thisDLoc = document.location; strwrite = ...
本文实例讲述了JavaScript获得当前网页来源页面(即上一页)的方法。分享给大家供大家参考。具体如下: 下面的JS代码通过document.referrer获得来源页面地址 <!DOCTYPE html> <html> <body> The ...
本文实例讲述了JS实现获取当前URL和来源URL的方法。分享给大家供大家参考,具体如下: index.html: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name=...
在用iframe的时候都会做分页操作 iframe内部的url跳转将不能直接通过iframe的src属性来获得,下面与大家分享下iframe的当前url的获取方法
当前url http://localhost:8888/select?aa=001&bb=002 var http = require(‘http’); var URL = require(‘url’); http.createServer(function(req, res){ var arg = url.parse(req.url).query; //方法一arg =...
url.js是一款可以非常实用方便的操纵网页URL地址的js插件。通过url.js你可以设置和获取当前URL的参数,也可以对当前URL的参数进行更新,删除操作,还可以将当前URL的参数显示为json字符串或是一个对象形式。
在WEB开发中,时常会用到javascript来获取当前页面的url网址信息,在这里是我的一些获取url信息的小总结。 下面我们举例一个URL,然后获得它的各个组成部分:http://i.cnblogs.com/EditPosts.aspx?opt=1 1、[removed...
当然我们可以在后台中获取参数的值,然后在前台js代码中获取变量的值,具体做法请参考我的这篇文章:JavaScript获取后台C#变量以及调用后台方法。 其实我们也可以直接在js中获取请求的参数的值,通过使用[removed]....