|zyciis| 如何知道打开我这个页面的上一个页面的名称叫什么

zyciis705 2008-02-20 11:50:58
如我有页面
A.aspx
B.aspx
C.aspx
然后我在这三个页转来转去
然后现在我想知道我的上一个页面是什么

开始我用
alert(window.history(-1).name)
也就是用history -1 -2 -3 这样直到找到他的名字不和我当前的网页相同的就行了
但上面的方法出错
然后我就用window.opener 但因为我这个不是打开窗口所以只得到 undefind

要怎么做

谢谢
...全文
92 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaojing7 2008-02-20
  • 打赏
  • 举报
回复
//设置或获取对象指定的文件名或路径。   
<script>
alert(window.location.pathname)
</script>

//设置或获取整个 URL 为字符串。
<script>
alert(window.location.href);
</script>

//设置或获取与 URL 关联的端口号码。
<script>
alert(window.location.port)
</script>

//设置或获取 URL 的协议部分。
<script>
alert(window.location.protocol)
</script>

//设置或获取 href 属性中在井号“#”后面的分段。
<script>
alert(window.location.hash)
</script>

//设置或获取 location 或 URL 的 hostname 和 port 号码。
<script>
alert(window.location.host)
</script>

//设置或获取 href 属性中跟在问号后面的部分。
<script>
alert(window.location.search)
</script>
patchclass 2008-02-20
  • 打赏
  • 举报
回复
要看你是用服务器端代码还是js的 document.referrer 服务器的 是参考服务器变量里面的 HTTP_REFERER
  • 打赏
  • 举报
回复
<table width=100% cellpadding=0 cellspacing=0 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>
<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><tr><td>



运行如下: thisURL: [http://www.sinoeb.cn/js/js%E8%8E%B7%E5%8F%96url.html]
thisHREF: [http://www.sinoeb.cn/js/js%E8%8E%B7%E5%8F%96url.html]
thisSLoc: [http://www.sinoeb.cn/js/js%E8%8E%B7%E5%8F%96url.html]
thisDLoc: [http://www.sinoeb.cn/js/js%E8%8E%B7%E5%8F%96url.html]
thisDLoc = document.location;
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisTLoc: [http://www.sinoeb.cn/js/js%E8%8E%B7%E5%8F%96url.html]
thisPLoc: [http://www.sinoeb.cn/js/js%E8%8E%B7%E5%8F%96url.html]
thisTHost: [www.sinoeb.cn]
thisHost: [www.sinoeb.cn]
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
thisHPage: [js%E8%8E%B7%E5%8F%96url.html]
thisUPage: [js%E8%8E%B7%E5%8F%96url.html]



参考这个例子
  • 打赏
  • 举报
回复
设置或获取对象指定的文件名或路径。
<script>
alert(window.location.pathname)
</script>

设置或获取整个 URL 为字符串。
<script>

alert(window.location.href);
</script>
设置或获取与 URL 关联的端口号码。
<script>
alert(window.location.port)
</script>

设置或获取 URL 的协议部分。
<script>
alert(window.location.protocol)
</script>

设置或获取 href 属性中在井号“#”后面的分段。
<script>
alert(window.location.hash)
</script>

设置或获取 location 或 URL 的 hostname 和 port 号码。
<script>
alert(window.location.host)
</script>

设置或获取 href 属性中跟在问号后面的部分。
<script>
alert(window.location.search)
</script>
  • 打赏
  • 举报
回复
document.URL
当前页用
  • 打赏
  • 举报
回复
document.referrer
JS的用他来获取
  • 打赏
  • 举报
回复
呵呵,不是这么弄的,要利用头属性,获取然后做判断比较获得
  • 打赏
  • 举报
回复
不过你的分真多啊
一问都是100分的
访问真八字排盘系统介绍: 1、八字排盘 八字排盘是将年月日时按照天干地支的形式进行排列,一个时间单位代表了一个柱。八字由年柱、月柱、日柱和时柱共四个柱组成,也被称为四柱八字。八字学中基于中国阴阳五行、天干地支与刑冲克害、以及民间盲派的神煞论等方式,进一步预测爱情顺遂、工作高低、姻缘好坏、财富高低、学业成就、身体健康等事的学问。 八字排盘由以下元素组合:年月日时四柱、大运干支、胎元 、流年干支、十神、地势、神煞等。生辰八字不只是把干支历计算出来,而还要遵守月令、节令的强弱,时辰的阴阳变化进行校正。排盘分析,就是根据出生者的性别、天干地支的阴阳五行关系、进一步推算出来的一套方法论,给预测者做人生吉凶的参考数据,在未来事业、财运、婚姻、家庭等问题时,能做出风险较低的决策。 八字排盘怎么看 八字排盘由年、月、日、时四柱组成,每柱包含一个天干和一个地支,共八个字。年柱代表出生的年份,月柱代表出生的月份,日柱代表出生的日期,时柱则代表出生的时辰。每个柱的干支组合都会对个人的命运产生影响。天干地支旁边标注的正财、偏财、偏印、正印、比肩、劫财、食神、伤官、正官、七杀等,称为十神。 2、八字排盘软件介绍 我们是腾讯云市场金牌合作伙伴,广州正规软件开发公司,开发的八字排盘系统数据最全面精准,我们八字排盘采用最精确的排盘程序,而且运用“真太阳时”,进行更精确的时间划分。大家都知道我们使用的北京时间,是统一规定的标准时间。而八字排盘需要相对于太阳方位的天文时间,即平太阳时。我们国家地大物博,北京时间19时,哈尔滨已经夜幕降临,而新疆却还是太阳高挂,这时哈尔滨的天文时间可能在20:00以后,而新疆的天文时间可能在16时以前。北京时间是东经120度经线的平太阳时,如果您出生地的经度与北京时间所处的经度差异较大,或者处于单数时间点的前后,比如6点差一刻,8点,10点15分等

61,129

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧