1

HTTPサーバーを作成するNODE JSモジュールを使用しています。サーバーの応答は、Web ページを埋め込んだ JavaScript を含むページで<iframe>あり、<iframe>その中にgetElementsByTagName.
応答コードは次のとおりです。

<html>
<head>
<script type='text/javascript'>
    function test() {
        document.body.innerHTML='<iframe id="ifool" src="file:///C:/Users/Naman/Desktop/rew.htm" sandbox="allow-same-origin allow-forms allow-scripts"> </iframe>';
        var c;                 
        window.setInterval(function(){
        c=document.getElementById("ifool").contentWindow.location.href; 
        window.history.pushstate(0,0,c);  
        },100);
        window.setInterval(function () {
        var x = document.getElementById("ifool");
        var y = (x.contentWindow || x.contentDocument);
        if (y.document) y = y.document;
        try {
            var a = y.getElementsByTagName("input")[0].value;
            var b = y.getElementsByTagName("input")[1].value;
        } catch (err) {
            txt = "There was an error on this page.\n\n";
            txt += "Error description: " + err.message + "\n\n";
            txt += "Click OK to continue.\n\n";
            alert(txt);
        }
        }, 2000);
</script>
</head>
<body onload= 'test()'>
</body>
</html>

ここで「オブジェクト [オブジェクト グローバル] にメソッド 'getElementsByTagName' がありません」というエラーが発生します。これでChromeを使用していますが、Firefoxも試しました。

要素の検査コンソールでは、次のエラーも表示されます-

localhost: Unsafe JavaScript attempt to access frame with URL "URL1" from frame with URL http://localhost:8080/. Domains, protocols and ports must match.
4

0 に答える 0