location.href 用法浅析

xiaoxiao2022-06-23  50

问题提出: 在做原型设计时候,对于静态页面的链接,这样写 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]
转载请注明原文地址: https://www.6miu.com/read-4953067.html

最新回复(0)