- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须在模式窗口中加载页面(内部 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/
我遇到过这个 html: 上面的html和这个有什么区别: 最佳答案 来自MDN page on the tag : 对于 type 的属性标签,可能的值是: 提交:按钮将表单数据提交给服务器
Button button= (Button) findViewbyID(R.id.button); 和 Button button = new Button(this); 有什么区别? 最佳答案 有
我是一名优秀的程序员,十分优秀!