Popup Code

dogilim

Regular Member
Joined
May 16, 2016
Messages
428
Reaction score
97
Hey I have a js popup code that works on desktop as intended but on mobile it is not poping under the main tab it is rather opening on main screen. Can anybody help me with this?

Code:
var popURL = "url";var popShown = false;
 
function doOpen(url) {
    if (popShown == true) {
        return false;
    }
      win = window.open(url, 'yp', 'menubar=0,resizable=1,width=1,height=1');
    win.moveTo(150000, 150000);
   win.blur();
       if (win) {
        popShown = true;
    }
    return true;
}
 
function setCookie(cname, cvalue, extime) {
  var d = new Date();
  d.setTime(d.getTime() + extime);
  var expires = "expires="+ d.toUTCString();
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
 
function getCookie(cname) {
  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  for(var i = 0; i <ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}
 
function initPop() {
    if (!getCookie('popShown')) {
      if (document.attachEvent) {
         document.attachEvent('onclick', checkTargetPop);
      } else if (document.addEventListener) {
         document.addEventListener('click', checkTargetPop, false);
      }
   }
}
 
function checkTargetPop(e) {
   if(jQuery(e.target).closest('#cstk').length || jQuery(e.target).closest('#preroll').length || jQuery(e.target).closest('.fa-home').length) {return;}
      if (!getCookie('popShown')) {
      var win = doOpen(popURL);
      setCookie('popShown', 1, 1 * 60 * 60 * 1000);
   }
   }
initPop();
 
Back
Top