var win = open('test.htm','abc');function a(){
s = win.location.href;
p = s.lastIndexOf("/");
pe = s.indexOf("?");
if(pe == -1) pe = s.length;
s = s.substring(p+1,pe);
if(s =="test.htm"){ alert("yes") }
}
s = win.location.href;
p = s.lastIndexOf("/");
pe = s.indexOf("?");
if(pe == -1) pe = s.length;
s = s.substring(p+1,pe);
if(s =="test.htm"){ alert("yes") }
}
子窗口是表单提交打开的:<form method=post action="te.asp" target=abc>
te.asp在打开后一段时间跳转到test.htm
判断这个abc窗口的url是否跳转到了test.htm
通过location.href可以获得
var win = window.open("some.htm", "_blank", "width=203,height=202");
alert(win.location.href);
var win;
function a(){
var s = win.location.href;
p = s.lastIndexOf("/");
pe = s.indexOf("?");
if(pe == -1) pe = s.length;
s = s.substring(p+1,pe);
if(s =="test.htm"){ alert("yes") }
}
function b(){
win=open('about:blank','abc');
while(!win){;}
document.form_name.submit();
}
</script>
<form action="test.asp" target="abc" name="form_name">
<input type="button" onclick="b();" value="submit"><input type="button" value="check" onclick="a()">
</form>
在test.htm回调父窗口的函数更简单<body onload="opener.xxx()">。
<body>
<a href="test2.htm" target="abc">test2.htm</a>
<input type=button value=test onclick="testFun();" ></body>
<script>
function testFun()
{
window.open("javascript:if( (/test2\.htm/ig).test(window.location)) top.close(); else alert('???Ҫ?رէ);","abc")
}
</script>
</html>
<body>
<a href="test2.htm" target="abc">test2.htm</a>
<input type=button value=test onclick="testFun();" ></body>
<script>
function testFun()
{
window.open("javascript:if( (/test2\.htm/ig).test(window.location)) top.close(); else alert('Window will not be colsed.');","abc")
}
</script>
</html>