`
yipbxx
  • 浏览: 60377 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

showModalDialog打开showModalDialog设置_self无效

    博客分类:
  • js
阅读更多
很多TX在开发过程中会用到showModalDialog,今天我说下自己在开发过程中碰到的问题:
1、如果直接通过showModalDialog弹出窗体,如果关闭子窗口需要刷新父窗口,在子窗体head里面加上<base target="_self"/>     
<meta http-equiv="pragma"   content="no-cache">,target="_self" 指明不开新的窗口,相对的_blank,是在新窗口打开文件。
2、如果父窗体是showModalDialog窗体,在在父窗体打开showModalDialog窗体,如果关闭子窗体时要需要刷新父窗体,需要关闭父窗体重新打开。参照下面的例子。
a.html打开showModalDialog窗体b.html,在b.html代开showModalDialog窗体c.html
关闭c.html刷新b.html,此时单单使用第一种方法就无法达到预期效果(但是<base target="_self"/>还是要加在head里面),此时就需要关闭b.html,让a.html再次打开b.html.
代码如下:

a.html
<html>      
<head>      
     
<meta http-equiv="pragma"   content="no-cache">      
</head>      
    <script type="text/javascript">      
     
    function test(){      
     
        var ret = window.showModalDialog("b.html", window,      
                'dialogWidth:500px;dialogHeight:520px;status:no;help:no');      
     
        if(ret == 1){      
            window.location.reload();      
        }      
    }      
</script>      
<body>      
<input type="button" onclick="test();" value="button"/>      
     
</body>      
</html> 



b.html
<html>      
<head>      
<base target="_self"/>      
<meta http-equiv="pragma"   content="no-cache">      
</head>      
    <script type="text/javascript">      
     
function closes() {      
     
window.returnValue=1;      
window.close();      
     
    }      
    function test(){      
     
        var ret = window.showModalDialog("c.html", 'checkout',      
                'dialogWidth:500px;dialogHeight:520px;status:no;help:no');      
     
        if(ret == 1){      
            window.location.replace("b.html");      
            //window.location.reload();      
        }      
    }      
     
     
      </script>      
</script>      
<body>      
bbbbbbbbbbbbbbbbbbbbbb      
<input type="button" onclick="test();" value="button"/>      
<input type="button" onclick="closes();" value="close"/>      
<script>         
      alert("加载B.html页面");         
</script>      
</body>      
</html> 


c.html
<html>      
<head>      
<base target="_self"/>      
<meta http-equiv="pragma"   content="no-cache">      
</head>      
    <script type="text/javascript">      
     
    function test() {      
     
window.returnValue=1;      
window.close();      
    }      
</script>      
<body>      
cccccccccccccccc      
<input type="button" onclick="test();" value="close"/>      
</body>      
</html> 


参照:http://www.iteye.com/problems/37060
分享到:
评论

相关推荐

    解决三层或心上showModalDialog的问题_2

    解决三层或心上showModalDialog的问题_2

    window.showModalDialog打开跨域的页面并取到返回值

    主页面用window.showModalDialog的时候,如果直接打开其它系统的页面,这时候别人的页面在window.returnValue=1;这样返回值的时候,主页面是取不到返回值的,原因就是因为跨域了.

    showModalDialog打开窗体接收返回值

    在JavaScript编程中,`showModalDialog` 是一个古老但仍然被一些开发者使用的函数,用于以模态对话框的形式打开一个新的窗口。这个对话框会阻止用户与父窗口进行交互,直到对话框关闭。在这个过程中,我们可以传递...

    解决三层或心上showModalDialog的问题_js

    解决三层或心上showModalDialog的问题_js

    针对window.showmodaldialog弹出窗体无刷新的详细使用

    - `window`:对话框打开时的上下文,通常为空字符串或`self`,表示当前窗口。 - `features`:对话框的样式和行为参数,例如宽度、高度、位置、是否允许滚动等,用分号隔开。 2. **返回值** `window....

    showmodaldialog的用法收集

    要防止`showModalDialog`或`showModelessDialog`弹出新窗口,可以在被打开的HTML文档中添加`&lt;base target="_self"&gt;`标签。这将确保所有链接都在当前窗口中打开,而不是新窗口。 ### 三、刷新`showModalDialog`和`...

    showModalDialog和showModelessDialog使用心得

    1. **刷新问题**:使用`showModalDialog`时,如果页面中有`&lt;base target="_self"&gt;`,直接刷新可能会导致意外的行为。可以通过监听键盘事件,阻止F5键的默认刷新行为,确保页面状态的一致性。 2. **返回数据**:从...

    showModalDialog实例

    1. **BackTap.jsp**:这是主页面,它调用了`showModalDialog`函数来打开一个新的窗口`Doback.jsp`。在`backModal`函数中,我们看到`showModalDialog`的参数包括对话框的URL(`Doback.jsp`)、初始对话框位置(空字符...

    使用selenium测试showModalDialog模态对话框

    这段代码首先定义了一个JavaScript字符串,用于重写 `showModalDialog` 方法,将其替换为 `window.open` 函数,这样对话框将以非模态窗口的形式打开,Selenium 就可以继续执行并选中这个新窗口。然后,代码模拟点击...

    showModalDialog参数使用详解

    在JavaScript的世界里,`showModalDialog`是一个古老但仍然有用的函数,用于打开一个模态对话框,展示用户需要交互的信息。这个功能在处理用户输入、确认操作或展示详细信息时非常实用。本篇文章将深入探讨`...

    google不支持window.showModalDialog问题解决方案

    This is a `window.showModalDialog()` shim using a modal HTML5 `&lt;dialog&gt;` element and ECMAScript 6 Generators. It was tested in the latest Google Chrome with the *Enable Experimental JavaScript* flag ...

    Window.ShowModalDialog使用手册_对话框 .txt

    `showModalDialog()` 是 Internet Explorer 4 及以上版本支持的方法,用于打开模态对话框。模态对话框会阻塞用户与主窗口的交互,直至关闭。 ##### showModelessDialog() `showModelessDialog()` 是 Internet ...

    避免 showModalDialog 弹出新窗体的原因分析

    showModalDialog和showModelessDialog 一、showModalDialog和showModelessDialog有什么不同? showModalDialog:被打开后就会始终保持输入焦点。除非对话框被关闭,否则...base target=”_self”&gt;就可以了。这句话一

    showModalDialog

    "showModalDialog"是JavaScript中的一个古老但仍然有用的弹出窗口方法,用于在浏览器环境中打开一个新的对话窗口。这个方法在Web开发中主要用于创建模态对话框,即那些阻止用户与页面其余部分交互直到对话框被关闭的...

    showModalDialog跨域解决例子

    然而,当尝试使用`showModalDialog`在不同源之间打开页面时,同样会遭遇跨域限制。标题"showModalDialog跨域解决例子"表明我们将探讨如何克服这个限制。 首先,理解跨域的原理至关重要。同源策略是浏览器为了安全而...

    解决window.showModalDialog跨域返回值

    在JavaScript中,`window.showModalDialog`是一个古老但仍然有用的函数,用于打开一个模态对话框,用户在对话框中进行交互,直到关闭对话框为止。然而,当涉及到跨域时,`showModalDialog`面临一个问题:它无法正确...

    showModalDialog参数传递和获

    在JavaScript中,`showModalDialog`是一个古老的浏览器API,用于打开一个模态对话窗口,它在用户与对话框交互之前阻止了对父窗口的访问。这个API在现代Web开发中已经逐渐被淘汰,但由于某些老旧系统的存在,理解其...

    showModalDialog用法

    在这段代码中,我们首先定义了对话框的特征(在这里设置了高度和宽度为0),然后调用`showModalDialog`方法打开对话框,并接收返回值。返回值通过逗号分隔,分别赋值给不同的表单元素。 4. **关闭对话框并返回值**...

    window.showModalDialog模式对话框和 window.open的区别

    `window.showModalDialog` 和 `window.open` 都是JavaScript提供的两种打开新窗口的方法,但它们在功能和使用场景上有着显著的区别。 首先,我们来详细探讨`window.showModalDialog`。`showModalDialog`方法用于...

Global site tag (gtag.js) - Google Analytics