【问题标题】:How do I close a window after the user clicks on the close button in file upload?用户单击文件上传中的关闭按钮后如何关闭窗口?
【发布时间】:2012-02-15 23:18:22
【问题描述】:

当用户点击文件上传中的取消按钮时,我们需要关闭弹出窗口本身。

  1. main.html
  2. popup.html

popup.html 包含<input type="file"

现在我们有一个要求,当用户点击文件上传窗口中的取消按钮时popup.html也应该关闭。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html> 
<head> 
    <script language="javascript"> 
    function openModalDlg() { 
        window.open( "test.html", "", 'width=400,height=100'); 
    } 
    </script> 
</head> 
<body> 
    <p> 
        Click 
        <a href="#" onclick="openModalDlg();">here</a> 
        to open modal dialog 
    </p> 
</body> 
</html> 

【问题讨论】:

  • Main.html

    点击这里打开模态对话框

标签: javascript


【解决方案1】:

您可以使用window.close 方法:

<input type="button" value="Close" onclick="window.close();" />

【讨论】:

  • 函数whenInFocus() { alert(document.getElementById("ch").value); if(document.getElementById("ch").value=="1") { window.close(); } window.onfocus = null; }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-17
  • 2012-09-23
  • 2012-09-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多