How to make a modal window in HTML5 and CSS3 popup automatically

落花浮王杯 提交于 2019-12-12 01:34:50

问题


I found some code online allowing me to create and design a modal window for visitors to sign up to our newsletter, but i want this modal window to popup automatically when the index page is opened. So far i have only been able to find modal windows that rely upon the user clicking on a hyperlink. Is there a function i can use to automatically open the modal window or a way to automatically load a hyperlink.

This is the link i used to create my modal window. Link


回答1:


You can use keyframe animations (support). Something like:

.modalDialog {
   /* other styles */
   animation: showup .5s;
}
@keyframes showup { to { opacity: 1; } } 

Be careful with pointer-events though. They won't work in any version of IE or Opera - see support for pointer-events in CSS.

A really simple demo I just did.




回答2:


Try this it worked for me

<script type="text/javascript">    
    $(function () {    
        $("#dialog").dialog({    
            modal: true,    
            autoOpen: false,
            title: "jQuery Dialog",    
            width: 300,    
            height: 150    
        });    
        $("#btnShow").click(function () {    
            $('#dialog').dialog('open');    
        });    
    });    
</script>

Reference: Open-Show-jQuery-UI-Dialog-Modal-Popup-on-Button-Click




回答3:


You can always enclose the link to modal window in a span or div. then on page load using jquery use the .click() function to autoload it.



来源:https://stackoverflow.com/questions/14413982/how-to-make-a-modal-window-in-html5-and-css3-popup-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!