更改JavaScript上的SRC iframe不起作用



我试图在JS中加油,但我无法成功。i框架总是空的,没有新窗口SRC的内容。如果我将src放在iframe的工作中(我不能这样做,因为我需要ID到SRC,并且在JS功能上得到了(

(

html:

<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-lg">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;</button>
    </div>
    <div class="modal-body">
  <iframe src=""  id="iframePOP" style="zoom:0.60" width="99.6%" height="250" frameborder="0"></iframe>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default text-center" data-dismiss="modal">close</button>
    </div>
  </div>
</div>

JS:

 function ShowPopup(id) {

        $('#myModal').on('show', function () {
                   document.getElementById("iframePOP").src="/Game.aspx?GameId=" + id;

        });
        $('#myModal').modal({ show: true })
    }

我也尝试过:

 function ShowPopup(id) {
        var frameSrc = "/Game.aspx?GameId=" + id;

        $('#myModal').on('show', function () {
            $('iframe').attr("src", frameSrc);

        });
        $('#myModal').modal({ show: true })
    }

您是否尝试过将整个域名分配到var frameSrc

编辑:尝试更改$('#myModal').on('show', function () { ... } into $('#myModal').is(':visible', function(){ ... });,并确保您引用的模式的ID正确。如果那不起作用,请尝试此$('#myModal').on('show.bs.modal', function (e) { ... })

最新更新