我的网页上有一个按钮。单击按钮后,将出现一个带有一些文本的弹出窗口。在这里,我需要在该弹出窗口中显示另一个 HTML 页面 我在下面给出了我的代码,请帮助我
<!doctype html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,500">
<link type="text/css" rel="stylesheet" href="popModal.css">
</head>
<body>
<button id="notifyModal_ex1" class="btn btn-primary">Example</button>
<div id="content2" style="display:none">
ghjgh
</div>
<script src="popModal.js"></script>
<script>
$(function(){
$('#notifyModal_ex1').click(function(){
$('#content2').notifyModal({
duration : 1500,
placement : 'center',
overlay : true,
type : 'notify',
onClose : function() {}
});
});
});
</script>
</body>
</html>
最佳答案
尝试使用 jQuery 的 load()
:
$('#content2').load("page/url").notifyModal()
显示加载消息:
$('#content2').text("Loading, please wait...").load("page/url").notifyModal()
或者在加载结束时打开模式:
$('#content2').load("page/url", function() {
$('#content2').notifyModal();
})
如 load() docs
中所述:
Load data from the server and place the returned HTML into the matched element.
因此它将加载一个 html 响应并将其附加到目标元素。
关于javascript - 使用 Javascript 在弹出窗口中显示页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34633627/