javascript - 使用 Javascript 在弹出窗口中显示页面

标签 javascript php html

我的网页上有一个按钮。单击按钮后,将出现一个带有一些文本的弹出窗口。在这里,我需要在该弹出窗口中显示另一个 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/

相关文章:

javascript - 通过http将 Angular 设置变量作为对象

javascript - 如何访问两者都需要: 'ngModel' and controller properties on directive

javascript - 基于javascript中的状态字段动态着色动态行数据

javascript - Firebase equalTo 不工作

PHP 无法加载动态库 "libMagickWand"

php - 真正的随机数

html - SVG 靠右对齐

javascript - 如何将 HTML 内容拆分为适合屏幕的页面?

php - 使用ajax登录检查

html - 在 td 元素内分组内容