javascript - 弹出html页面没有返回值?

标签 javascript html

请问有人可以帮我吗?以下 JavaScript 代码适用于 IE9 及以上版本和 Firefox,但较低版本的 IE(8,7) 不支持。

function SetName() {
    var a = sessionStorage.getItem("sent");
    var b = window.opener.document.getElementById("tclass").value;
    var c = window.opener.document.getElementById("ttype").value;
    var noPMMCode = window.opener.document.getElementById("noPMMCode").value;
    var noLTMMCode = window.opener.document.getElementById("noLTMMCode").value;
    var noLEMMCode = window.opener.document.getElementById("noLEMMCode").value;
    var noSTMMCode = window.opener.document.getElementById("noSTMMCode").value;
    if (window.opener != null && !window.opener.closed && b == "Material" && c == "PT" && noPMMCode != null) {
        var txtName = window.opener.document.getElementById("PMMC" + a);
        txtName.value = document.getElementById("ddlNames").value;
    } else if (window.opener != null && !window.opener.closed && b == "Material" && c == "LT-NORMAL" && noLTMMCode != null) {
        var txtName = window.opener.document.getElementById("LTMMC" + a);
        txtName.value = document.getElementById("ddlNames").value;
    } else if (window.opener != null && !window.opener.closed && b == "Material" && c == "LT-EMPANEL" && noLEMMCode != null) {
        var txtName = window.opener.document.getElementById("LEMMC" + a);
        txtName.value = document.getElementById("ddlNames").value;
    } else if (window.opener != null && !window.opener.closed && b == "Material" && c == "ST" && noSTMMCode != null) {
        var txtName = window.opener.document.getElementById("STMMC" + a);
        txtName.value = document.getElementById("ddlNames").value;
    }
    window.close();
}

提前谢谢..

最佳答案

window.opener 在默认安全级别下的 IE 中不起作用。

一种选择是使用location.href将子窗口重定向到与父窗口相同域中的页面,然后使用window.opener

关于javascript - 弹出html页面没有返回值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30432414/

相关文章:

javascript - 让 Jquery 记住 attr() 和数据

javascript - $ 未定义..但它是无法找到的 fancybox

javascript - django 和 d3.tsv,不工作

html - 为什么背景图像不显示? (CSS)

javascript - 使用 JavaScript 以慢动作替换 HTML

javascript - 0.8.0更新后 meteor 白屏?

javascript - 我如何使用 XML 设计样式

html - 自定义 CSS 聊天气泡

html - 如何更改 HTML 仪表的背景颜色?

javascript - 跳过隐藏的标签索引