使用Javascript弹出显示页面

时间:2016-01-06 12:50:51

标签: 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>

1 个答案:

答案 0 :(得分:0)

尝试使用jQuery&#39; load()

$('#content2').load("page/url").notifyModal()

显示加载消息:

$('#content2').text("Loading, please wait...").load("page/url").notifyModal()

或者在加载结束时打开模态:

$('#content2').load("page/url", function() {
    $('#content2').notifyModal();
})

load() docs中所述:

  

从服务器加载数据并将返回的HTML放入匹配的元素中。

因此它会加载一个html响应,追加到目标元素。

相关问题