gpt4 book ai didi

jquery - 如何在 Bootstrap 模态对话框中显示 URL : On button click

转载 作者:行者123 更新时间:2023-12-03 22:37:28 24 4
gpt4 key购买 nike

我必须在模式窗口中加载页面(内部 URL)。我一直在使用 window.showModalDialog(url, null, features) 但这在 Safari、Chrome 上无法正常工作。所以我们决定改用 Bootstrap 的模式对话框。我无法完成这项工作。你知道我可能做错了什么吗?

    //imports
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">


//activate content as modal
$(document).ready(function(){
$('#test_modal').modal({

});
}

.......
.......

$("#btnSubmit").click(function(){
var url = constructRequestURL();
$('#test_modal').modal(data-remote=url,data-show="true");
});


-----
-----
<div class="modal fade" id="test_modal">
</div>

最佳答案

如果您要继续沿着 Bootstrap 路径前进,您可以查看此处:jsfiddle - remote URI in Bootstrap 2.3.2 modal

请注意,URL 需要位于同一域(尽管您提到它是“内部”),或者远程站点的 Access-Control-Allow-Origin 设置需要允许您的域。因此请记住,fiddle 演示实际上无法从 example.com 加载内容。

<button type="button" class="btn" data-toggle="modal" data-target="#myModal" data-remote="http://example.com">Launch modal</button>

<div id="myModal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<!-- remote content will be inserted here via jQuery load() -->
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>

您不需要为此编写任何自定义 JavaScript - Bootstrap 会根据 data-remote="http://example.com/whatever"和 data-target="等数据属性知道要做什么#myModal”等

请参阅 Bootstrap modal docs 的相关部分欲了解更多信息...

编辑:事实证明,动态更改远程 URL 并不像想象的那么容易。希望this answer将为您提供进一步帮助。

关于jquery - 如何在 Bootstrap 模态对话框中显示 URL : On button click,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18220462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com