<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><frameset rows="80,*" frameborder="NO" border="0" framespacing="0" >
<frame src="topFrame.htm" name="topFrame" scrolling="NO" noresize >
<frame src="mainFrame.htm" name="mainFrame">
</frameset>
<script>
//这里不知道怎么写了,试了半天总说对象是空
window.frames.mainFrame.window.frames.iframe.src = 'http://www.google.com';
</script>
<noframes></noframes>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><frameset rows="80,*" frameborder="NO" border="0" framespacing="0" >
<frame src="topFrame.htm" name="topFrame" scrolling="NO" noresize >
<frame src="mainFrame.htm" name="mainFrame">
</frameset>
<script>
//这里不知道怎么写了,试了半天总说对象是空
window.frames.mainFrame.window.frames.iframe.src = 'http://www.google.com';
</script>
<noframes></noframes>
</html>
解决方案 »
- eval提示缺少引号
- jsTree树形列表刷新回滚问题。
- 验证显示问题?
- Extjs的一些问题
- 求救:怎么用JavaScript选取用户输入的关键字所在的在的文章中的段落,正则表达式!
- 在下拉列表框的下拉列表选项中移动鼠标,如何动态提示相应Option的内容,请高手指教
- 如何得到一个只要内部线,不要外部线的表格
- 请教 <input type="file" id=“...”/> 在前台怎么用赋值的方式给它指定文件路径?? 在线等。。。
- 关于js线程的问题
- 滚动条的不稳定因素
- js用location.href=表达,<a href="aaa.htm" target="_blank">
- 是while()出问题了吗?
另:请注意控件的命名.
window.frames["mainFrame"].frames["iframeName"].location.href = "http://www.google.com";
我是想index.htm一加载就要执行这样的代码的
this is main frame
<iframe name="myFrame" src=""></iframe>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.frames["myFrame"].location="http://www.csdn.net";
//-->
</SCRIPT>
</body>
你可以这样做通过onload事件等对象创建完毕
<script>
function loadFrame()
{
//这里不知道怎么写了,试了半天总说对象是空
//window.frames.mainFrame.window.frames.iframe.src = 'http://www.google.com';
}
window.document.onLoad = loadFrame;
</script>
我其实是用asp.net的,别的页面传递参数给index.aspx(就是上面我说的index.htm),然后我在index.aspx.cs中根据接收到的参数往页面里写javascript代码,觉得那个iframe里面调用哪个页面,所以不能在mainframe里写,只能在index.aspx里写了,还有什么其他的建义吗?
可是我现在发现为什么无法在index.htm页面访问其中的topFrame和mainFrame元素呢???
我用alert(window.frames.length)取到的居然是"0" ?!?!?
用window.frames["topFrame"].若干属性 都是undefined!!!
百思不得其解!!!
说简单一点吧!!!
代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<SCRIPT LANGUAGE=javascript>
<!--
//我怎么在这里访问下面这两个frame的各种属性????
//-->
</SCRIPT>
</head>
<frameset rows="80,*" frameborder="NO" border="0" framespacing="0" >
<frame src="topFrame.htm" id="topFrame" name="topFrame" scrolling="NO" noresize >
<frame src="http://www.baidu.com" id="mainFrame" name="mainFrame">
</frameset>
<noframes></noframes>
</html>就在这个页面访问其中的那两个frame元素???