简体   繁体   English

如何显示动画gif弹出并在几秒钟后发出警报

[英]How to show an animated gif as pop up and an alert after some seconds

I have an HTML page and unfortunatly I don't know much about it. 我有一个HTML页面,不幸的是,我对此并不了解。 In my HTML page there is a simple button that redirect to another website. 在我的HTML页面中,有一个简单的按钮可重定向到另一个网站。 What I would like to do is to show a popup that advise the user that he is moving to another site. 我想做的是显示一个弹出窗口,通知用户他正在移动到另一个站点。 If he accepts so he is redirected, if not then he stays in page. 如果他接受,那么他将被重定向,否则,他将停留在页面中。

I've made a graphic for all the process described before and it is a simple gif animated. 我已经为上述所有过程制作了图形,并且它是一个简单的gif动画。 what I wanna do is this: 我想做的是这样的:

The user click on the button the gif animated pop up (and all the background is unclickable with a dark color if it's possible to do) after 2 seconds the alert pop up next to the gif. 用户单击gif动画弹出按钮(如果可能的话,所有背景都是不可单击的,并且深色,如果有可能,则单击该按钮),然后在gif旁边弹出警报。

I've an example of what I wanna do. 我有一个我想做的事的例子。 http://imgur.com/8dAf3Xp http://imgur.com/8dAf3Xp

Try this sample i created in js fiddle 试试我在js小提琴中创建的这个样本

fiddle 小提琴

I use 2 overlapping divs to achieved this, wait 2 seconds and the pop-out will automatically show. 我使用2个重叠的div来实现此目的,请等待2秒钟,弹出窗口会自动显示。

Hope this helps :) 希望这可以帮助 :)

HTML HTML

    <div id = "pop-out">
    <div id = "message">
        Message goes here
        <button class = "ok"> Ok </button>
    </div>
</div>
<div id = "container">
    Content goes here 
    <button>You can't click me</button>
</div>

CSS CSS

div#pop-out {
    position: absolute;
    top: 0;
    left: 0;
    background-color: rgba(255,255,255,.2);
    width: 100%;
    height: 100%;
    z-index: 1;
    display: none;
}
div#message {
    width: 50%;
    height: 100px;
    margin: 0 auto;
    border: 1px solid red;
    text-align: center;
    line-height: 100px;
}

jQuery jQuery的

$(document).ready(function(){
    setTimeout(function(){
              $("#pop-out").show();     
       },2000);

    $("button.ok").click(function(){
        $("#pop-out").hide();
    });
});

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

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