【问题标题】:Calling a function in parent file from child frame?从子框架调用父文件中的函数?
【发布时间】:2010-09-01 05:00:36
【问题描述】:

我有一个函数可以在“frame.html”中调整我的framesetcol 宽度比:

<frameset id="set" cols="*,*" FRAMESPACING=0 BORDER=3 BORDERCOLOR=#eeeeee>
    <frame src="index.html">
    <frame src="index2.html"> 
    <noframes></noframes> 
</frameset> 

从“frame.html”调用该函数时工作正常,但是我想从子文件“index.html”调用所述函数...该函数需要保留在父文件中才能正常运行。 .. 如何从index.html 调用frame.html 中的函数

【问题讨论】:

    标签: javascript html function


    【解决方案1】:

    试试parent.functionName() 应该可以的。

    编辑


    为了确保范围正确,您可能应该调用window.parent.functionName(),而不是确保它实际上是引用的框架父级

    编辑 2


    查看this answer,它似乎可以处理相同的 chrome 问题。

    希望对你有帮助!

    【讨论】:

    • 没关系,Chrome 不允许引用“file://”协议,上传到我的网络服务器后,一切正常...谢谢
    猜你喜欢
    • 1970-01-01
    • 2017-11-20
    • 2020-03-25
    • 2020-06-18
    • 1970-01-01
    • 1970-01-01
    • 2019-11-27
    • 2017-03-11
    相关资源
    最近更新 更多