页面test.htm中的代码为:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<frameset rows="90,*" frameborder="no" border="0" framespacing="0">
<frame name="topFrame" src="test1.htm" frameborder="0" border="0" scrolling="auto">
<frame name=""mainFrame" src="http://xxx.com/login" frameborder="0" border="0" scrolling="auto">
</frameset>
</html>页面test1.htm中的代码为:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=JavaScript>
window.onload=function(){
top.mainFrame.document.loginform.Username.value='用户名';
top.mainFrame.document.loginform.Password.value='密码';
top.mainFrame.document.loginform.submit();
}
</script>
</head>
<body>
</body>
</html>想通过在test1.htm中的javascript置值,提交另外一个页面中的表单,但是不起作用,另外一个框架中的页面http://xxx.com/login没有被响应提交,请教大家如何可以实现我说的这种效果?谢谢!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<frameset rows="90,*" frameborder="no" border="0" framespacing="0">
<frame name="topFrame" src="test1.htm" frameborder="0" border="0" scrolling="auto">
<frame name=""mainFrame" src="http://xxx.com/login" frameborder="0" border="0" scrolling="auto">
</frameset>
</html>页面test1.htm中的代码为:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=JavaScript>
window.onload=function(){
top.mainFrame.document.loginform.Username.value='用户名';
top.mainFrame.document.loginform.Password.value='密码';
top.mainFrame.document.loginform.submit();
}
</script>
</head>
<body>
</body>
</html>想通过在test1.htm中的javascript置值,提交另外一个页面中的表单,但是不起作用,另外一个框架中的页面http://xxx.com/login没有被响应提交,请教大家如何可以实现我说的这种效果?谢谢!
解决方案 »
- BD01AB568EA56EE75E5030C5187D173B这是什么编码?
- 可以自己写别人网站的搜索框添加到自己网站上吗?
- 怎么打开一个拥有独立的session的IE新窗口
- 关于网页里面的一段JS代码老是出错,不知道错在哪里?请高手指点
- 如何生成类似google suggest那样的效果
- 求解决办法
- 饼状图
- 数组是如何定义的?嘻嘻,如此简单的问题我确实不会,但马上给分
- 请问如何将一个vbs中的数组中的值传到一个javascript中呢?
- “innerHTML”,“insertRow”之类的语句是出之标准的javascript吗?
- jquery 想写一个图片轮播
- showbo斑竹 请教个extjs combo小问题
<frame name=""mainFrame"
去掉个引号
你的test1 在执行 onload的时候
mainFrame的元素是否已经加载好了。
如果那时没有加载好。怎么可能让你执行你想要执行的功能呢?
在mainFrame
中放一个全局变量 isLoadOver=false;
onload事件中 isLoadOver=True;在test中
循环调用,如果isLoadover为false就过一段时间再看一次。
如果为true执行提交方法,然后停止计时器
top.mainFrame.document.loginform能取到么?
在test1.html中
在主页面中获得主页面中的框架中页面的元素或者是变量函数
方法是:
var iframe = document.getElementById("mainframes");
iframe.onload = function() {
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
//alert(iframe.contentWindow.a); //获得变量 不兼容
//iframeDoc.getElementById('divId') //获得元素
}在主页面中一个框架中获得两一个或者自己框架元素或变量方法是:在主页面中一个框架中的js代码
alert(top.mainframe.a); //ie
<!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>Untitled Document</title>
<style type="text/css">
body { margin:0; padding:0; }
#divId { width:500px; height:500px; }</style>
</head><body>
<div id="divId">
<iframe id="mainframe" name="mainframes" src="1.html" frameborder="0" width="100%" height="100%"></iframe>
</div>
<div id="diId">
<iframe id="main" name="mains" src="3.html" frameborder="0" width="100%" height="100%"></iframe>
</div>
<script type="text/javascript">
/*var iframe = document.getElementById("mainframes");
iframe.onload = function() {
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
//alert(iframe.contentWindow.a);
}*/
</script>
</body>
</html>1.html
<!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>Untitled Document</title>
<script type="text/javascript">
var a = 1;
function fns() {
return 2;
}
</script>
</head><body>
<div id="diid">sfsf</div>
<div>sfsf</div>
<script type="text/javascript">
alert(top.mains.b);
</script>
</body>
</html>3.html
<!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>Untitled Document</title>
<script type="text/javascript">
var b = 9;
</script>
</head><body>
<div id="di">sfsfs</div>
</body>
</html>
window.onload=function(){
var iframe = document.getElementById("mainFrame");
iframe.onload = function() {
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.loginform.Username.value='用户名';
iframeDoc.loginform.Password.value='密码';
iframeDoc.loginform.submit();
}}
html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<frameset rows="90,*" frameborder="no" border="0" framespacing="0">
<frame name="topFrame" src="test1.htm" frameborder="0" border="0" scrolling="auto">
<frame name="mainFrame" id='mainFrame' src="http://xxx.com/login" frameborder="0" border="0" scrolling="auto">
</frameset>
</html>
这儿加id了吗?