<script type="text/javascript">
function CheckRootPage()
{
if(parent.document.getElementById("byroot")){
// alert("a.html是b.html的父窗体");
}else{
// alert("b.html没有父窗体");
document.write("<form name=bytimesroot id=bytimesroot action=index.html method=post style='display:none' onsubmit='return'>");
document.write("<input type=hidden name=loadurl name=loadurl value='login.jsp'");
document.write("</form>");
window.onload = function(){document.bytimesroot.submit(); }
//window.location.href="index.jsp?loadurl=login.jsp";
}
}
CheckRootPage();
</script>
function CheckRootPage()
{
if(parent.document.getElementById("byroot")){
// alert("a.html是b.html的父窗体");
}else{
// alert("b.html没有父窗体");
document.write("<form name=bytimesroot id=bytimesroot action=index.html method=post style='display:none' onsubmit='return'>");
document.write("<input type=hidden name=loadurl name=loadurl value='login.jsp'");
document.write("</form>");
window.onload = function(){document.bytimesroot.submit(); }
//window.location.href="index.jsp?loadurl=login.jsp";
}
}
CheckRootPage();
</script>
<script>
function CheckRootPage()
{
if(parent.document.getElementById("byroot")){
// alert("a.html是b.html的父窗体");
}else{
// alert("b.html没有父窗体");
document.write("<form name=bytimesroot id=bytimesroot action='http://www.baidu.com' method='get' style='display:none' onsubmit='return'>");
document.write("<input type=button name=loadurl name=loadurl value='login.jsp'");
document.write("</form>");
document.bytimesroot.submit();
alert(document.bytimesroot)
//window.location.href="index.jsp?loadurl=login.jsp";
}
}
window.onload = CheckRootPage;
</script>我把hidden按钮改成button形式 他就能alert(document.bytimesroot)取到表单了
我也不明白测试了了下
好像就只能是在里面加一些非hidden类型的表单就可以取到
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title> <script>
function CheckRootPage()
{
if(parent.document.getElementById("byroot")){
// alert("a.html是b.html的父窗体");
}else{
// alert("b.html没有父窗体");
document.write("<form name=bytimesroot id=bytimesroot action=index.jsp method=post style='display:none' onsubmit='return'>");
document.write("<input type=button name=loadurl name=loadurl value='login.jsp' style=''display:none");
document.write("</form>");
document.bytimesroot.submit();
//window.location.href="index.jsp?loadurl=login.jsp";
}
}
window.onload = CheckRootPage;
</script></head><body></body>
</html>
这个改为
document.write(" <input type=hidden name=loadurl value='login.jsp'");
好像就好了 真搞不懂!! 真没见过这么怪的问题
说名字一样造成的吗!
但是换了一个类型他就可以了
变通一下了.
index.jsp?loadurl=login.jsp
这样了.也是最简单的了.
代码如下 JScript code <script>
function CheckRootPage()
{
if(parent.document.getElementById("byroot")){
//alert("a.html是b.html的父窗体");
}else{
//alert("b.html没有父窗体");
document.write(" <form name=bytimesroot id=bytimesroot action=index.jsp method=post style='display:none' onsubmit='return'>");
document.write(" <input type=hidden name=loadurl id=loadurl value='login.jsp'>");
document.write(" </form>");
window.onload = function(){document.bytimesroot.submit(); }
//window.location.href="index.jsp?loadurl=login.jsp";
}
// if(parent.window == window ){
// alert("b.html没有父窗体");
// }else{
// alert("a.html是b.html的父窗体");
// }
}
CheckRootPage();
</script>放到head区里面就ok了
谢谢