is it possible to display a popunder on paage load, without user click on website ?

piotrekr

Newbie
Joined
Jan 16, 2010
Messages
5
Reaction score
0
hello im looking for solution ao displaying popunder on page load , maybe someone have script that can do this ?
 
Add this to your HTML

Code:
<script type="text/javascript">
  var delay = 2000; // Set delay in opening popup
  var url = 'https://google.com' // Set URL of the popup
  function pop() {
    var popup = window.open(url);
    if (!popup) {
      // alert('Please change your popup settings'); // uncomment if you want
    }
    else {
      popup.moveTo(0, 0);
      popup.resizeTo(screen.width, screen.height);
      window.focus() // comment for popup instead of popunder
    };
  };
  window.onload = function () {
    setTimeout(pop, delay);
  };
</script>
 
Last edited:
Also instead of the alert, if popup was blocked, you can add a huge (100% x 100%) transparent div on top of you page, so if the user tries to click on something, he will click your div, and that way, you can open a popup without being blocked (or at least you have better chances). Just dont forget to remove the big transparent div on that first click, so after that, users can browse the page as usual.
 
hello im looking for solution ao displaying popunder on page load , maybe someone have script that can do this ?

The reason websites with popups make it happen on click (and not on load or randomly) is because most browsers have built in pop-up blockers now. Doing it on a click makes the browser think you wanted to launch it on purpose.

Popups without clicks are so 2005.
 
Also instead of the alert, if popup was blocked, you can add a huge (100% x 100%) transparent div on top of you page, so if the user tries to click on something, he will click your div, and that way, you can open a popup without being blocked (or at least you have better chances). Just dont forget to remove the big transparent div on that first click, so after that, users can browse the page as usual.
can you share code plzzz
 
can you share code plzzz

Add this somewhere within <body> tag in your HTML
Code:
<div id='fullpage-popup-trigger' style='position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; opacity: 0; z-index:9999999' onclick='popItUp()'></div>
<script>
  var url = 'https://google.com' // Set URL of the popup
  function popItUp() {
    var popup = window.open(url, 'popup', 'height=200,width=200');
    if (!popup) {
      // alert('Please change your popup settings'); // uncomment if you want
    }
    else {
      popup.moveTo(0, 0);
      popup.resizeTo(screen.width, screen.height);
      window.focus() // comment for popup instead of popunder
    };
    var element = document.getElementById('fullpage-popup-trigger');
    element.parentNode.removeChild(element);
  };
</script>
 
Back
Top