Web Design: A summary of JavaScript pop-up windows

Source: Internet
Author: User
Tags window
Javascript| pop-up window | design | Web Page Design | questions

Author: Rodechon, ldj_work#126.com, reprint please keep integrity.

1. Refreshing Web pages without prompting

We have not found that some pages, refresh, will pop up a prompt window, click "OK" will refresh. And some pages do not prompt, not pop-up prompts the window, directly refreshed. If the page does not have a form, the prompt window does not pop up if the page has form forms,

A) <form method= "POST" ...>
The prompt window will pop up
b) <form method= "Get" ...>
does not eject

2 How JavaScript refreshes the page

Window.location.reload ();

Use window.open () pop-up pop-up window to refresh the parent window
Window.opener.location.reload ()
Using the Window.showdialog pop-up mode window
Window.dialogArguments.location.reload ();

3.javascript pop-up window code

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

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
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

  4. mode window data not flush (cache) problem

Add the following statement to the JSP page

<%
Response.setheader ("Pragma", "No-cache");
Response.setheader ("Cache-control", "No-cache");
Response.setdateheader ("Expires", 0);
%>

  5, in the Mode window, the link pops up a new window problem

Join <base target= "_self" between

  6. No prompt to close the page method

function Closewin () {
var ua = navigator.useragent; var ie = navigator.appname== "Microsoft Internet Explorer"? True:false;
if (IE) {
var ieversion = parsefloat (ua.substring (Ua.indexof ("MSIE") +5,ua.indexof (";", Ua.indexof ("MSIE")));
if (ieversion< 5.5) {
var str = ';
Document.body.insertAdjacentHTML ("BeforeEnd", str);
Document.all.noTipClose.Click ();
} else {
Window.opener =null; Window.close ();
}
}else{
Window.close ()
}
}



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.