Skip to main content
Participant
September 26, 2018
Answered

Popups

  • September 26, 2018
  • 2 replies
  • 438 views

I have a client that needs a jpg to popup on the home page five seconds after it loads. Anyone have suggested code I can use to accomplish this? Dreamweaver CC 2018.

    This topic has been closed for replies.
    Correct answer osgood_

    Any good with code? You can use the setTimeOut function in javascript - example below will provide you a solution:

    <!DOCTYPE html>

    <html lang="en">

    <head>

    <meta charset="UTF-8">

    <title>Pop Up</title>

    <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="

    crossorigin="anonymous"></script>

    <script>

    $(document).ready(function(){

    $('.pop_up').hide();

    setTimeout(function(){

    $('.pop_up').fadeIn();

    }, 5000);

    $('.close_pop_up').css('cursor' , 'pointer').click(function(){

    $('.pop_up').fadeOut();

    });

    });

    </script>

    <style>

    body {

    margin: 0;

    }

    .pop_up {

    position: fixed;

    width: 100%;

    height: 100%;

    background-color: rgba(0, 0, 0, 0.5);)

    }

    .pop_up_content {

    width: 300px;

    margin: 0 auto;

    text-align: center;

    padding: 25px;

    background-color: #fff;

    position: relative;

    top: 50%;

    transform: translateY(-50%);

    }

    </style>

    </head>

    <body>

    <div class="pop_up">

    <div class="pop_up_content">

    <h1>Pop Up</h1>

    <button class="close_pop_up">Close</button>

    </div>

    <!-- endpop_up_content -->

    </div>

    <!-- end pop_up -->

    </body>

    </html>

    2 replies

    Nancy OShea
    Community Expert
    Community Expert
    September 26, 2018
    Nancy O'Shea— Product User & Community Expert
    osgood_Correct answer
    Legend
    September 26, 2018

    Any good with code? You can use the setTimeOut function in javascript - example below will provide you a solution:

    <!DOCTYPE html>

    <html lang="en">

    <head>

    <meta charset="UTF-8">

    <title>Pop Up</title>

    <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="

    crossorigin="anonymous"></script>

    <script>

    $(document).ready(function(){

    $('.pop_up').hide();

    setTimeout(function(){

    $('.pop_up').fadeIn();

    }, 5000);

    $('.close_pop_up').css('cursor' , 'pointer').click(function(){

    $('.pop_up').fadeOut();

    });

    });

    </script>

    <style>

    body {

    margin: 0;

    }

    .pop_up {

    position: fixed;

    width: 100%;

    height: 100%;

    background-color: rgba(0, 0, 0, 0.5);)

    }

    .pop_up_content {

    width: 300px;

    margin: 0 auto;

    text-align: center;

    padding: 25px;

    background-color: #fff;

    position: relative;

    top: 50%;

    transform: translateY(-50%);

    }

    </style>

    </head>

    <body>

    <div class="pop_up">

    <div class="pop_up_content">

    <h1>Pop Up</h1>

    <button class="close_pop_up">Close</button>

    </div>

    <!-- endpop_up_content -->

    </div>

    <!-- end pop_up -->

    </body>

    </html>

    Participant
    September 26, 2018

    Thank you!

    Where do I insert the link for the .jpg to show?

    Legend
    September 26, 2018

    You would insert your image link as below:

    <div class="pop_up_content">

    <img src="myImage.jpg" alt="">

    <button class="close_pop_up">Close</button>

    </div>

    <!-- endpop_up_content -->