码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript页面刷新与弹出窗口问题的解决方法

时间:2014-07-11 12:58:16      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:style   http   java   color   使用   os   

1. [代码][JavaScript]代码     ?
一、无提示刷新网页 
大家有没有发现,有些网页,刷新的时候,会弹出一个提示窗口,点“确定”才会刷新。而有的页面不会提示,不弹出提示窗口,直接就刷新了. 如果页面没有form,则不会弹出提示窗口。 
如果页面有form表单, 
  a)< form method="post" ...> 会弹出提示窗口 
  b)< form method="get" ...> 不会弹出 
二、javascript刷新页面的方法 
window.location.reload(); 
使用window.open()弹出的弹出窗口,刷新父窗口 
window.opener.location.reload() 
使用window.showDialog弹出的模式窗口 
window.dialogArguments.location.reload(); 
三.javascript弹出窗口代码 
下面给两个弹出屏幕居中窗口的例子 
复制代码 代码如下:
window.open()方式 
function ShowDialog(url) { 
var iWidth=300; //窗口宽度 
var iHeight=200;//窗口高度 
var iTop=(window.screen.height-iHeight)/2; 
var iLeft=(window.screen.width-iWidth)/2; 
window.open( http://www.huiyi8.com/yuanma/?
url,"Detail","Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no, 
Width="+iWidth+" ,Height="+iHeight+",top="+iTop+",left="+iLeft 
); 

window.showModalDialog方式 
function ShowDialog(url) { 
var iWidth=300; //窗口宽度 
var iHeight=200;//窗口高度 
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" 
); 



注意这里的第二个参数,window 
四、模式窗口中,链接弹出新窗口问题 
在< /head >和< body >间加入< base target="_self" > 
五、无提示关闭页面的方法 
复制代码 代码如下:
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() 

JavaScript页面刷新与弹出窗口问题的解决方法,布布扣,bubuko.com

JavaScript页面刷新与弹出窗口问题的解决方法

标签:style   http   java   color   使用   os   

原文地址:http://www.cnblogs.com/xkzy/p/3833900.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!