简体   繁体   English

Popup.js-调用弹出窗口

[英]Popup.js - call a popup

I know this is really basic, but I can't find an answer. 我知道这真的很基础,但是我找不到答案。 How can I call a popup within a condition? 如何在条件内调用弹出窗口? For example: 例如:

if(error.length != 0){
    console.log(error);     
    popup({
        content : '<p>Not allowed</p>',
        type    : 'html'
    });         
}

My page contains an import 我的页面包含一个导入

<script src="<c:url value='/resources/js/jquery.popup.min.js' />"></script>

I get an error: 我收到一个错误:

Uncaught ReferenceError: popup is not defined 未捕获ReferenceError:未定义弹出窗口

Try this: 尝试这个:

if(error.length != 0){
    console.log(error); 
    var popup = ({
        content : '<p>Not allowed</p>',
        type    : 'html'
    }); 
}

I don't see any direct loading in jquery.popup.min.js you can use color box . 我看不到可以直接使用color box jquery.popup.min.js任何直接加载。 see the example. 参见示例。 More demos here. 这里有更多演示。

 if(1){ // your condition here $.colorbox({html:"<h1>Welcome</h1>"}); } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="http://www.jacklmoore.com/colorbox/example1/colorbox.css" rel="stylesheet"/> <script src="http://www.jacklmoore.com/colorbox/jquery.colorbox.js"></script> 

USING CLICK ON LINK IN popup.js 在popup.js中使用单击链接

 function check(val){ //console.log(error); if(val != 0){ $('.html_popup').popup({ content : '<h1>This is some HTML for non zero</h1>', type : 'html' }); }else{ $('.html_popup').popup({ content : '<h1>This is some HTML for 0</h1>', type : 'html' }); } } 
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="http://docs.toddish.co.uk/js/plugins/jquery.popup.min.js"></script> <link href="http://docs.toddish.co.uk/css/plugins/popup.css" media="all" type="text/css" rel="stylesheet"> <a class="html_popup" style="width:100px;" onclick='check(1)'> click me</a> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM