从子框架调用父文件中的函数?

时间:2022-09-01 16:00:20

I have a function that resizes the col width ratio of my frameset in "frame.html":

我有一个在“frame.html”中调整我的框架集的col width ratio的函数:

<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

当从“frame”调用时,该函数可以正常工作。但是,我要调用子文件中的上述函数“index.html”…这个函数需要保持在父文件中才能正常运行……我如何在坐标系中调用我的函数。html的index . html

1 个解决方案

#1


11  

Just try parent.functionName() it should work.

试试parent.functionName()应该没问题。

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

为了确保范围是正确的,您应该调用windows .parent. functionname(),而不是确保引用的实际上是框架父类

Edit 2

编辑2


Check out this answer it seems to handle the same chrome issue.

看看这个答案,它似乎处理同样的chrome问题。

Hope it helps!

希望它可以帮助!

#1


11  

Just try parent.functionName() it should work.

试试parent.functionName()应该没问题。

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

为了确保范围是正确的,您应该调用windows .parent. functionname(),而不是确保引用的实际上是框架父类

Edit 2

编辑2


Check out this answer it seems to handle the same chrome issue.

看看这个答案,它似乎处理同样的chrome问题。

Hope it helps!

希望它可以帮助!