无法从<iframe>内的页面获取段落的innerHTML

时间:2019-09-05 21:39:49

标签: javascript html iframe innerhtml paragraph

我正在尝试获取段落的innerHTML,因此我可以检查段落是否与某个段落匹配,然后根据结果将用户发送到另一页面。我该如何解决?

var input = document.getElementById('serial').value;
    var validator = document.createElement('iframe');
    validator.src = "http://awebsite.com/wvkey=" + input;
    body.appendChild(validator);
    var status = validator.contentWindow.document.getElementById('status').innerHTML;
    if (status === "Key Status: Active") {
        window.location.assign("../dashboard/index.html");
    }
    else {
        window.location.assign("../support/keys/invalid/index.html");
    }

注意:忽略该“ body”变量,它已在代码的前面声明。 iframe和页面本身会出现,但是它们无法按预期工作,也无法将用户发送到任何地方。

0 个答案:

没有答案