parent.main.hehe1();
或者
top.main.hehe1();
或者
top.main.hehe1();
解决方案 »
- 求助,麻烦各位高手帮忙看一下这段是什么意思..不是很懂
- JS在操作cookie时,cookie的过期日期存在Bug吗?
- 跪求富媒体。右下角浮动广告带关闭按钮的!!
- 用window.open禁用工具栏菜单栏以后,可否用js在打开的子页面中恢复之?
- javascript问题:一个2行2列的表格,怎么按顺序改变表格的颜色?望高手不吝赐教。
- iframe当scrolling="auto",无论如何总会留出滚动条的宽度,有办法解决吗?
- 关于Jquery框架下javascript combobox输入动态取值问题
- 设置下拉列表框的默认值
- 一个较难的问题-怎样消除滚动条?
- 有没有必要一定要学JavaScript ,如果要学请老鸟们推荐一本全面点的好书!好奇的菜鸟!!
- 正则表达式
- javascript 这样提交表单为什么出错?
<frameset cols="150,*">
<frame name="left" src="left.html">
<frame name="main" src="main.html">
</frameset>left.html
<script type="text/javascript">
function callMainFunction()
{
parent.main.hehe();
}
</script>
<input type="button" onclick="callMainFunction()" />main.html
<script type="text/javascript">
function hehe()
{
alert("hehe");
}
</script>
parent表示父层
由于你目前在b页面,所以你不能访问到a页面元素
此时你用top或者parent就可以访问a页面和b页面元素了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="aa.js" type="text/javascript"></script>
</head><frameset rows="80,*" cols="*" frameborder="no" border="0" framespacing="0">
<frame src="topFrame.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
<frameset cols="80,*" frameborder="no" border="0" framespacing="0">
<frame src="leftFrame.html" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame" />
<frame src="mainFrame.html" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>
</frameset>
<noframes><body>
</body>
</noframes></html>
main 页<!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=gb2312" />
<title>无标题文档</title>
<script src="aa.js" type="text/javascript" ></script>
</head>
<script>
commit=function(){
left.main.demo();
}
</script>
<body>
<input type="button" id="btn_test" value="test" onclick="commit();"/>
</body>
</html>
left 页<!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=gb2312" />
<title>无标题文档</title>
<script src="aa.js" type="text/javascript" ></script>
<script>
demo=function()
{
document.getElementById("txt_content").value="aaa";
}
</script>
</head>
<form name="aaa">
<input type="text" id="txt_content" name="txtcontent"/>
<label name="lbl_text" id="rrr" onclick="demo();">aaaa</label>
</form>
<body>
</body>
</html>启动 frame页面把两个页面都打开,我想在main 页调 left页函数,怎么调
所以
parent.leftFrame.demo()
==========
parent.leftFrame.location.reload()
把页面显示到main页里,
common,A,Bjs写在common文件里,A页面调common文件的代码显示到B页面这样的还需要用到跨页面调用/显示等于还是用到parent