从子框架调用父文件中的函数? [英] Calling a function in parent file from child frame?
问题描述
我有一个函数可以调整frame.html中的 frameset
的宽度比例<:c $ c> col :
< frameset id =setcols =*,*FRAMESPACING = 0 BORDER = 3 BORDERCOLOR =#eeeeee>
< frame src =index.html>
< frame src =index2.html>
< noframe>< / noframes>
< / frameset>
从frame.html调用该函数时可以正常工作,但是我想从子文件index.html...该函数需要保留在父文件中才能正常运行......如何在 frame.html
从 index.html
只要试试 parent.functionName()
它应该可以工作。
编辑
为了确保范围正确,您应该调用 window.parent.functionName()
来代替以确保它实际上是被引用的框架父
编辑2
< hr>
查看这个答案它似乎处理相同的铬问题。
希望它有帮助!
I have a function that resizes the col
width ratio of my frameset
in "frame.html":
<frameset id="set" cols="*,*" FRAMESPACING=0 BORDER=3 BORDERCOLOR=#eeeeee>
<frame src="index.html">
<frame src="index2.html">
<noframes></noframes>
</frameset>
The function works fine when called from "frame.html", However i want to call said function from the child file "index.html"... the function needs to remain in the parent file in order to run properly... How can I call my function in frame.html
from index.html
Just try parent.functionName()
it should work.
Edit
Just to be sure that the scope is correct you should probably call window.parent.functionName()
instead to be sure that it is actually the frames parent that is referenced
Edit 2
Check out this answer it seems to handle the same chrome issue.
Hope it helps!
这篇关于从子框架调用父文件中的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!