海东的技术资料

  博客园 :: 首页 ::  :: 联系 :: 订阅 订阅 :: 管理 ::
  205 随笔 :: 22 文章 :: 678 评论 :: 60 Trackbacks
1  IE6和IE7关闭窗口时提示和不提示
2 上传文件立即显示效果图,在ie7中可以用滤镜
 
<!--以下均支持IE6和IE7,不支持Firefox2.0,其他浏览器未经测试-->
<script type="text/javascript"> 
function CloseWin() //这个会提示是否关闭浏览器

window.opener
=null;
window.open(
"","_self");
window.close(); 
}

如果在框架中关闭整个框架页面的话如下
这个是不提示关闭
function  aa  (   )
      
{
          
           
if (window.confirm('您确认要退出系统吗?'))
           
{
             top.opener
=null;
             top.open(
"","_self");
             top.close();
             window.close;
             
            }

         
else
          
{return false;}
         
        
        
      }


function Preview(imgFile)

document.getElementById(
"pic").filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;

}
 
</script> 

<href="javascript:CloseWin();"> 点击这里无提示关闭当前窗口</a><br /> 

请选择要预览的图片:
<input type="file" onchange="javascript:Preview(this);" /><br />
<div id="pic" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);width:400px;height:200px;"></div> 
获取图片的大小
var img=new Image();
img.src=imgFile.value;
alert(img.fileSize);
alert(img.width);
alert(img.height);
posted on 2007-06-19 11:56 高海东 阅读(2009) 评论(7)  编辑 收藏 所属分类: ASP.NET 2.0

评论

#1楼  2007-07-06 11:47 Andy [未注册用户]
非常好,解决了我的问题,谢谢!
  回复  引用    

#2楼  2007-09-21 16:45 弦音 [未注册用户]
能不能实现点击IE7的关闭按钮提示关闭啊?!
  回复  引用    

#3楼  2007-11-29 14:41 Sutra [未注册用户]
@弦音
你可以参考一下 http://blogmover.redv.com 是怎么实现的。

//if (window.addEventListener) {
// window.addEventListener("beforeunload", doClose, false);
//}
//else if (window.attachEvent) {
// window.attachEvent("onbeforeunload", doClose);
//}
//else {
window.onbeforeunload = doClose;
//}
function doClose() {
var t = "───────────────────────\r\n您确定要离开 Blog Mover 吗?\r\n确定后未完成的操作你将无法控制。\r\n───────────────────────";
return t;
}
  回复  引用    

#4楼  2007-12-10 11:55 brucechen [未注册用户]
I've had the same issue... and did a bit of research on my own to see if I could find a work-around for this.

I have created a simple testing example online to try out different methods of opening new windows and having them self-close: http://sky.prohosting.com/savage25/AutoCloseExample.html
As you can see from the descriptions within it, IE6 and IE7 react differently in several of the cases. Hence the "issue" that IE7 has created...

In particular, the one that is causing me issues is the FORM submission using a "_blank" target window. It closes without confirmation in IE6, but does not in IE7.

A work-around that I discovered: IE7 may actually have become less secure when JAVASCRIPT redirects the current page (within the same window), and then this redirected-to site closes the window... the page then closes without any confirmation. I was able to use this "bug" (?) to my advantage as a work-around to solve the problem.

Instead of calling "window.close()" to close the current window... do this:

window.open('close.html', '_self');

Where "close.html" contains:

<html><body>
<script language="JavaScript">window.close();</script>
</body></html>

This should work in both IE6 and IE7 to close the current window without confirmation.
I am currently using it in my application and it works well.

Paul Narsavage
Bethlehem, PA, USA
savage_25 at yahoo.com

  回复  引用    

#5楼  2008-03-12 17:03 daweisun [未注册用户]
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "提示", "window.opener=null;window.open('', '_self');window.close()", true);

  回复  引用    

#6楼  2008-06-19 13:08 leesun [未注册用户]
恩,至少IE6,7都没问题,谢谢楼主
thanks!I 支持YOU
  回复  引用    


标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      


相关链接: