How to show a URL in Bootstrap Modal dialog: On button click

后端 未结 2 594
渐次进展
渐次进展 2020-12-15 12:34

I have to load a page (internal URL) in a modal window. I had been using window.showModalDialog(url, null, features) but this does not work properly on Safari,Chrome. So w

2条回答
  •  半阙折子戏
    2020-12-15 13:02

    If you're going to continue down the bootstrap path, you could take a look here: jsfiddle - remote URI in Bootstrap 2.3.2 modal

    Note that the URL will need to be on the same domain (though you mentioned it is "internal") or your domain will need to be allowed by the remote site's Access-Control-Allow-Origin settings. So keep in mind that the fiddle demo can't actually load content from example.com.

    
    
    
    

    You don't need to write any custom JavaScript for this - Bootstrap will know what to do based on the data-attributes like data-remote="http://example.com/whatever" and data-target="#myModal" etc.

    See the relevant section of the Bootstrap modal docs for more info...

    Edit: It turns out that changing the remote URL dynamically isn't as easy as it could be. Hopefully this answer will help you further.

提交回复
热议问题