【问题标题】:how to refresh a src of an iframe within a modal如何在模式中刷新 iframe 的 src
【发布时间】:2017-12-14 20:10:08
【问题描述】:

我在模型中有一个 iframe。 iframe 打开一个网站 eg.xxx 。从 xxx.com 我有多个按钮单击一个按钮,我被接管到 eg.xxx/yyy.html 。当我关闭对话框时,它仍然显示 xxx/yyy.html 而不是 xxx.com 。 我如何用 Javascript 解决这个问题?

部分模式代码:

<!-- Start Feature Section -->
<div class="section-modal modal fade" id="magazine-modal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-content">
        <div class="close-modal " data-dismiss="modal">
            <a href="../twt/index.html" style="color: #000000; font-size: 30px;" data-toggle="modal">
                <i class="fa fa-home"></i>
            </a>
            <!-- <div class="lr">
                 <div class="rl">
                 </div>
             </div>-->
        </div>
        <div class="container ">
            <div class="row">
                <div class="section-title text-center">
                </div>
            </div>
            <div class="row modal-body">
                <iframe src="https://www.pvrcinemas.com/magazines" target="_self" style="position:fixed; top:65px; left:0px; bottom:0px; right:0px; width:100%; height:95%;color:#000000; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;">
                    Your browser doesn't support iframes
                </iframe>
            </div>
        </div>
    </div>
</div>
<!-- End Feature Section -->

请帮助我。

【问题讨论】:

  • 部分类似于stackoverflow.com/questions/46289527/…,其中刷新 scr 属性是通过 javascript 完成的。如果您在 iframe 中添加一个 id,它将更容易定位该 frame 。帖子链接还保留了通过 localstorage 完成的选择...也许这是您的下一个问题?

标签: javascript css html modal-dialog


【解决方案1】:

在调用模态显示之前。只需使用所需的 url 设置 iframe src。

$('#magazine-modal').find("iframe").attr("src","https://www.pvrcinemas.com/magazines");
$('#magazine-modal').modal('show'); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-23
    • 2013-02-10
    • 1970-01-01
    • 2013-11-06
    • 2011-11-15
    • 2015-07-29
    • 2018-02-27
    • 2018-02-23
    相关资源
    最近更新 更多