Posted By

Ideandro on 03/21/11


Tagged

javascript popup


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Ideandro


Popup window


 / Published in: JavaScript
 

  1. var _POPUP_FEATURES = 'location=0, statusbar=0, menubar=0, scrollbars=1, width=480, height=640 ,top='+Math.floor((screen.height-640)/2)+' ,left='+Math.floor((screen.width-480)/2);
  2.  
  3. function isUndefined(v) {
  4. var undef;
  5. return v===undef;
  6. }
  7.  
  8. function raw_popup(url, target, features) {
  9. if (isUndefined(features)) features = _POPUP_FEATURES;
  10. if (isUndefined(target )) target = '_blank';
  11. var theWindow = window.open(url, target, features);
  12. theWindow.focus();
  13. return theWindow;
  14. }
  15.  
  16. function link_popup(src, features) {
  17. return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
  18. }
  19.  
  20. Uso HTML:
  21. <a href="pagina.htm" onclick="link_popup(this); return false;">Pagina</a>

Report this snippet  

You need to login to post a comment.