Window.open shows the sample code in the center of the page

  • 2020-03-30 01:06:53
  • OfStack

1. Js


<script type="text/javascript">  

function openwindow(url,name,iWidth,iHeight)  
{  
//Url to the address of the web page & NBSP;  
//Name web page name, can be blank & sponge;  
//IWidth & PI;  
//IHeight pop-up window height & NBSP;  
//Window.screen.height gets the height of the screen and window.screen.width gets the width of the screen.  
var iTop = (window.screen.height-30-iHeight)/2; //Get the vertical position of the window;    
var iLeft = (window.screen.width-10-iWidth)/2; //Gets the horizontal position of the window;    
window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');  
}  

</script>  

2. Call the method

<a href="javascript:void(0);" onclick="javascript:openwindow('a.html','',400,200);"> Go to the a</a>


Related articles: