Thursday, May 12, 2016

Popup new window center screen php javascript

First Create a javascript function for popup window. w=width , h=height of the window
 // Popup windows   
 function popupwindow(url, title, w, h) {  
        var left = (screen.width/2)-(w/2);  
        var top = (screen.height/2)-(h/2);  
        return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);  
 }  

Now make a php function to use this java-script function everywhere in php easily.

 /**  
  * Return pop up   
  * @author Sharif Ahmed  
  * @param str url  
  * @param str title/value  
  * @param int width  
  * @param int height  
  * @return return popup center windows  
  */  
 function my_anchor_popup($url,$title,$width,$height)   
   {  
     return '<a href="'.$url.'" onclick="popupwindow(\''.$url."','".$title."', '".$width."','".$height."'); return false;\">".$title.'</a>';  
   }   

No comments:

Post a Comment

Total Pageviews