【问题标题】:iframe parent.function() call is undefined when used in Phonegap在 Phonegap 中使用时,iframe parent.function() 调用未定义
【发布时间】:2011-05-24 20:58:50
【问题描述】:

大家好,提前感谢您的帮助。这是我的情况:

我安装了 Phonegap 0.9.5,并且正在 Eclipse 中制作应用程序。我的所有设置都很好,并且在我的 Phonegap 应用程序的应用程序 assets/www/index.html 中:

<iframe id='downloader' frameborder='0' style='width:100%' src='http://www.myste.com/mobile/index.html'></iframe>

http://www.myste.com/mobile/index.html 有这个按钮:

 <input style="position:relative;top:200px;z-index:5;" type="button" onclick="alert(parent.location.href)" value="DOES MOM EXIST?" />';

但由于某种原因,我返回一个“未定义”。我的最终目标是让 iframe 中的按钮调用父级(assets/www/index.html)中的函数:

onclick="parent.somefunction();"

谁能帮帮我?

【问题讨论】:

    标签: java javascript android iframe cordova


    【解决方案1】:

    应该类似于window.top.location.href

    【讨论】:

    • 这个 iframe 的父级是否在不同的域或子域上?
    • 父级是Phonegap的assets/www/index.html
    • iframe 是从哪里加载的?
    • Phonegap 的assets/www/index.html。
    • 很奇怪,不确定。我会先在 phonegap 之外尝试这个以排除变量,然后如果它有效,则将其放入 phonegap。
    猜你喜欢
    • 2016-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-08
    相关资源
    最近更新 更多