location.href 用法浅析

问题提出:

在做原型设计时候,对于静态页面的链接,这样写
onclick="location.href='http://localhost:8082/default.pr_automata.forward.do?nextPage=/OrderMan/page/newOrder1.jsp'">

估计是最常用的链接了!

这时候,就会出现一个问题:如果单纯的用

<a href="aa.html" target="">链接</a>

表示链接,你可以设置页面打开的地方,如:target="_self/_blank/_parent/_top",代表在当前页面/新打开页面/父页面/最顶端窗口 打开页面。但是如果用location.href 可怎么确定在哪打开啊!

解决方案:

self.location.href="/url" 当前页面打开新页面,与默认的location.href 或者是windows.location.href 或者是 this.location.href 效果一样

parent.location.href="/url" 在父页面打开新页面

top.location.href="/url" 在顶层页面打开新页面

怎么样,简单好用吧!



例子:

<FORM name="queryForm1" action="OPerCU.pr.prQueryCU.do" method="post" target="result">


</FORM>

<iframe name="result" frameborder="0" width="100%" height="420" scrolling="auto" marginheight="0" marginwidth="0"></iframe>
<script>
document.queryForm1.submit();
</script>



[url]http://www.css8.cn/css8_allhtml/form/200606/387.htm[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值