【问题标题】:How refresh Index(Parent), from inside another iframe如何从另一个 iframe 中刷新索引(父级)
【发布时间】:2015-07-09 06:17:38
【问题描述】:

需要帮助..

我有一个页面(index.html),在 index.html 里面有一个到 main.html 的 iframe。 在 main.html 中,我访问其他页面。示例 (productlist.html)。

在 Index.html 顶部有一个装有数量产品的购物车。

我想在 productlist.html 中(表单或输入)添加新产品并刷新 index.html,然后在 productlist.html 中继续(不在 main.html 中)。

我是怎么做到的?

index.html

    <li class="shoppingcar-total shoppingcar-resume-item">
        Total <span class="price">R$<ccom:content-block section="10022">
    <ccom:field id="TotalGeral" type="virtual" /></ccom:content-block></span>
        </li>

 <iframe src="Get?id_sec=111" id="main_frame"  name="main_frame" class="margin123" width="100%" scrolling="no"  frameborder="0" seamless="seamless"> Nao e possivel mostrar o frame</iframe>

main.html (Get?id_sec=111)

     <form action="Get?id_sec=116" method="post">
      <input type="submit" class="buy-button primary-button minimalist-button"
 title="Adicionar ao carrinho" id="boughtbutton1" name="Adicionar" value="Refresh" onsubmit="window.opener.location.reload();" />
    </form>

productlist.html (Get?id_sec=116)

ex: Item 1 price=$20
<button class="minus-button quantity-button button" type="submit" name="Adicionar" onclick="myFunc(document.getElementById('9950'));" value="-"> 

【问题讨论】:

    标签: javascript jquery html iframe frame


    【解决方案1】:

    在您的&lt;iframe&gt; JavaScript 代码中,您可以使用window.top 访问顶部框架(主HTML 文档)。请注意,所有内容都必须位于同一域中才能正常工作。

    假设您的主文档中有一个名为hello 的全局函数。您可以在 &lt;iframe&gt; 中的 JavaScript 中这样调用它:

    window.top.hello();
    

    还有其他通信方式,例如通过侦听postMessage 函数发布的数据。

    【讨论】:

    • 感谢您的帮助.. 我如何在我的案例中应用此功能?
    猜你喜欢
    • 2012-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-20
    • 1970-01-01
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多