*.location.href 用法:
top.location.href=”url” 在顶层页面打开url(跳出框架)
self.location.href=”url” 仅在本页面打开url地址
parent.location.href=”url” 在父窗口打开Url地址
this.location.href=”url” 用法和self的用法一致
if (top.location == self.location) 判断当前location 是否为顶层来 禁止frame引用
如果页面当中有自定义的frame的话,也可以将parent self top换为自定义frame的名称
效果就是在自定义frame窗口打开url地址
<input type="button" οnclick="window.location.href='../main/XX/XXX.jsp'" value="" />
<a href="javascript:void(0);" οnclick="javascript:location.href="http://www.166suncity.com";">
点击后跳转到http://www.166suncity.com</a>
------------------
window.location.href='index.jsp'中的"location"是什么意思?
是在本窗口中打开这个index.jsp链接的意思吗?
另外js中类似的打开链接的命令还有什么?
1. 是
2. document.all.linkId.click() |
location 当前文档的url
window.location.href= 'index.jsp '
<==>
window.location= 'index.jsp '
<==>
location= 'index.jsp '
----
<A href= "window.location= 'index.jsp ' "> LINK </A>
<==> <A href= "index.jsp "> LINK </A> |
window.open()
window.location.href= 'index.jsp '
self.location= 'index.jsp '
opener.location= 'index.jsp
location 是windows窗口内的一个对像,它主要功能是从当前的网页导向另外
一个网页,href是它的一个属性.通过它可以导向另外一个网页同时也刷新了此网页. |
-------------------------------------------------------
众所周知有关重定向分为前端(js)重定向和后台重定向。
在asp.net中遇到了页面1使用html按钮重定向问题,由于之前使用了window.open打开新的网页,但是从此页退回后第二次进入,则后台不会发生pageload事件(注意此处是第二次进入),当然不会捕捉到postback这个事件,怀疑是直接调用缓存里面的文件。
改为window.location.href()后问题解决,或者使用后台的Response.Redirect()问题一样解决。
但是又遇到了IE和firefox兼容问题,在网上找到的答案如下:window.location='UserAdd.aspx';"
还遇到了个问题超级链接怎么才能够跳出框架(firefox中),网上查到答案:
<a href="register.aspx" target="_parent">注册</a>
改为<a href='register.aspx' target='_top'>注册</a>