javascript – How to add an image popup when accessing the site


I would like to make a popup similar to the one from Kabum , but without a form, just an image and the option to close.

I searched and found this code:

<a href="#" onclick="'', 'Pagina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=10, LEFT=10, WIDTH=770, HEIGHT=400');">Clique para abrir a janela POP-up</a>  

But it opens a new page and I need it to stay on the same site as the Kabum example.


I couldn't see the kabum popup, but from what I understand in your question, you intend to do something like:

var close = document.getElementById('close');
var popup = document.getElementById('popup');

close.addEventListener("click", function() { = 'none';
#popup {
  position: absolute;
  margin: 0 auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0px 0px 50px 2px #000;
  padding-bottom: 5px;
#close {
  width: 100px;
  background-color: #cc0033;
  color: #ffffff;
  border: none;
  margin-left: 5px;
<div id="popup" class="popup">
  <img src="" alt="popup">
    <button id="close">Sair</button>

See working on jsfiddle

Scroll to Top