How to create a popunder for when someone clicks on any part of the site, open a new tab with another site? [closed]

-2

Hello! Does anyone know how to create a popunder for when a person clicks on any part of the website / blog open a new tab with another site? Thank you!

    
asked by anonymous 28.02.2017 / 16:10

1 answer

3

javascript function

var popunder="http://site.com/"
function loadpopunder(){
win2=window.open(popunder)
win2.blur()
window.focus()
}

We call this function in the onclick event of the opening tag body

    <body onclick="loadpopunder()">
  

If you want to open a site randomly, make an array of the desired sites in var popunder

var popunder=new Array()
popunder[0]="http://www....."
popunder[1]="http://www....."
popunder[2]="http://www....."
popunder[3]="http://...."
popunder[4]="http://...." 
//acrescente qtos elementos queira
  

and replace the variable win2 in the popunder function with   win2 = window.open (popunder [Math.floor (Math.random () * (popunder.length))])

    
01.03.2017 / 06:15