We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

cochambre on 07/12/06


Tagged

window popup open new blocking


Versions (?)


Who likes this?

15 people have marked this snippet as a favorite

jonhenshaw
xaviaracil
mate
panatlantica
nicolaspar
nutella
fael
vali29
heinz1959
visuallyspun
SpinZ
gAmUssA
jeradhill
jamesming
hans


Javascript Popup with Blocking detection


Published in: JavaScript 


  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 = window.open(url,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 

You need to login to post a comment.