Javascript Popup with Blocking detection

/ Published in: JavaScript
Save to your folder(s)

Copy this code and paste it in your HTML
  1. function popup(url,ancho,alto,id,extras){
  2. if(navigator.userAgent.indexOf("Mac")>0){ancho=parseInt(ancho)+15;alto=parseInt(alto)+15;}
  3. var left = (screen.availWidth-ancho)/2;
  4. var top = (screen.availHeight-alto)/2;
  5. if(extras!=""){extras=","+extras;};
  6. var ventana =,id,'width='+ancho+',height='+alto+',left='+left+',top='+top+',screenX='+left+',screenY='+top+extras);
  7. var bloqueado = "AVISO:\n\nPara ver este contenido es necesario que desactive\nel Bloqueo de Ventanas para este Sitio."
  8. //var bloqueado = "WARNING:\n\nIn order to use this functionality, you need\nto deactivate Popup Blocking."
  9. if(ventana==null || typeof(ventana.document)=="undefined"){ alert(bloqueado) }else{ return ventana; };
  10. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.