Home > Web Front-end > JS Tutorial > Solutions to JavaScript page refresh and pop-up window problems_javascript skills

Solutions to JavaScript page refresh and pop-up window problems_javascript skills

WBOY
Release: 2016-05-16 18:33:43
Original
1190 people have browsed it
1. Refresh the webpage without prompts
Have you noticed that when refreshing some webpages, a prompt window will pop up. Click "OK" to refresh. Some pages will not prompt and will refresh directly without popping up a prompt window. If the page does not have a form, no prompt window will pop up.
If there is a form on the page,
 a)< form method="post" ...> A prompt window will pop up
 b)< form method="get" ...> No
will pop up. 2. How to refresh the page using javascript
window.location.reload();
Use the pop-up window popped up by window.open() to refresh the parent window
window .opener.location.reload()
Use window.showDialog to pop up the modal window
window.dialogArguments.location.reload();
Three.javascript pop-up window code
Below are two examples of pop-up windows centered on the screen
Copy the code The code is as follows:

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 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.showModalDialog(
url,window,"dialogHeight: " iHeight "px;dialogWidth: " iWidth "px;
dialogTop: " iTop "; dialogLeft: " iLeft "; resizable: no; status: no;scroll:no"
);
}

Note the second one here Parameters, window
4. In the modal window, the link pops up a new window problem
Add < base target="_self" > between < /head > and < body > ;
5. How to close the page without prompting
Copy the code The code is as follows:

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 labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template