JavaScript Pop-up window center code _javascript Tips

Source: Internet
Author: User
<script language= "JavaScript" > Function Openwin (U, W, h) {var L = (screen.width-w)/2; var t = (screen.height-h)/2; var s = ' width= ' + w + ', height= ' + H + ', top= ' + t + ', left= ' + L; s + = ', Toolbar=no, Scrollbars=no, Menubar=no, Location=no, Resizable=no '; Open (U, ' Owin ', s); } </script> Test
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]


JavaScript Pop-up Window Center code

Here are two examples of a pop-up screen centered window

Copy Code code as follows:

window.open () way
function ShowDialog (URL) {
var iwidth=300; Window width
var iheight=200;//window Height
var itop= (window.screen.height-iheight)/2;
var ileft= (window.screen.width-iwidth)/2;
window.open (URL, "Detail", "Scrollbars=no,toolbar=no,location=no,direction=no,resizeable=no,
Width= "+iwidth+", height= "+iheight+", top= "+itop+", left= "+ileft";
}

window.showModalDialog Way

Copy Code code as follows:

function ShowDialog (URL) {
var iwidth=300; Window width
var iheight=200;//window Height
var itop= (window.screen.height-iheight)/2;
var ileft= (window.screen.width-iwidth)/2;
window.showModalDialog (Url,window, "dialogheight: +iheight+" px; dialogwidth: "+iwidth+" PX;
Dialogtop: "+itop+"; Dialogleft: "+ileft+"; Resizable:no; Status:no;scroll:no ");
}

Notice the second argument here, window

Users must enter information in this pop-up form before they can access other forms that are modal forms. Just use the second method.

JavaScript pop-up window centered four:

Copy Code code as follows:

function Selectcustomer () {
var itop = (window.screen.availheight-30-500)/2;
var ileft = (window.screen.availwidth-10-750)/2;
window.open (".. /customer/creditapprmanage.do?method=togetcustomer ",
"Searchcorp",
"Height=500,width=750,top=" +itop+ ", left=" +ileft+ ", toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location =no,status=no "
);
}

Description: 500 and 750 are hard-coded and can be passed in by parameter.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.