Javascript pop-up window Summary

Source: Internet
Author: User

1. No prompt to refresh the webpage
Have you found that when refreshing some webpages, a prompt window will pop up and click "OK" to refresh the page.
Some pages do not prompt. If the prompt window is not displayed, the page is refreshed directly.
If the page does not have a form,
The prompt window is not displayed.
If the page has a form,
A) <form method = "post"...>
A prompt window will pop up.
B) <form method = "get"...>
No


2. How to refresh the page with javascript

Window. location. reload ();

Use window. open () to refresh the parent window.
Window. opener. location. reload ()
Window. showDialog
Window. dialogArguments. location. reload ();


3. javascript pop-up window code 
The following are two examples of the screen center window
Window. open () method
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 Mode
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 ");
}

Note that the second parameter here,Window

4. The mode window data is not refreshed (cached)

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, a new window is displayed.

Add <base target = "_ self"> between

6. No way to close the page
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 ()
}
}

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.