load iframe in bootstrap modal

后端 未结 6 1629
青春惊慌失措
青春惊慌失措 2020-12-14 22:00

I want to load an iframe into a bootstrap modal and show a loader before the iframe is loaded. I am using a simple jquery click function, but it is not working. I do not und

6条回答
  •  無奈伤痛
    2020-12-14 22:39

    $('.modal').on('shown.bs.modal',function(){      //correct here use 'shown.bs.modal' event which comes in bootstrap3
      $(this).find('iframe').attr('src','http://www.google.com')
    })
    

    As shown above use 'shown.bs.modal' event which comes in bootstrap 3.

    EDIT :-

    and just try to open some other url from iframe other than google.com ,it will not allow you to open google.com due to some security threats.

    The reason for this is, that Google is sending an "X-Frame-Options: SAMEORIGIN" response header. This option prevents the browser from displaying iFrames that are not hosted on the same domain as the parent page.

提交回复
热议问题