奇数javascript XSS错误

奇数javascript XSS错误,javascript,html,xss,communication,Javascript,Html,Xss,Communication,我正在设计一种在iFrame之间通信的简单方法,并且我得到了一个奇怪的XSS错误,即使两个URL都有保存域 Unsafe JavaScript attempt to access frame with URL file:///home/bryre/sharedData/Programs/javascript/pong/htdocs/connectionWindow.html from frame with URL file:///home/bryre/sharedData/Programs/ja

我正在设计一种在iFrame之间通信的简单方法,并且我得到了一个奇怪的XSS错误,即使两个URL都有保存域

Unsafe JavaScript attempt to access frame with URL file:///home/bryre/sharedData/Programs/javascript/pong/htdocs/connectionWindow.html from frame with URL file:///home/bryre/sharedData/Programs/javascript/pong/htdocs/connectionTest.html. Domains, protocols and ports must match.
我需要把它们放在服务器上才能让它工作吗?代码如下:

ConnectionTest.html

<html>
<head>
    <title>connectionTest</title>
    <script src='connection.js'></script>
</head>
<body>
    <script>
        var windowToConnectTo = document.createElement('iframe')
        windowToConnectTo.src = 'connectionWindow.html'
        document.body.appendChild(windowToConnectTo)

        var connection = new Connection({});
        connection.connect(windowToConnectTo, 10);
    </script>
</body>

它们没有任何域,它们是本地文件。使用HTTP服务器访问它们。

它们没有任何域,它们是本地文件。使用HTTP服务器访问它们

<html>
<head>
    <title>connectionTest</title>
    <script src='connection.js'></script>
</head>
<body>
    <script>
        var connection = new Connection({});
    </script>
</body>
function Connection(commands){
this.inDiv = document.createElement('div')
this.inDiv.id = 'in'
this.inDiv.style.disply = 'none'
document.body.appendChild(this.inDiv)

this.commands = commands
}

Connection.prototype = {
attemptConnect: function(to){
    to.document = (to.contentWindow || to.contentDocument)
    if(to.document.document)
        to.document = to.document.document
    this.to = to.document.getElementById('in') //ERROR HAPPENS HERE
    if(this.to == null)
        return false
    return true
},
connect: function(to, retryRate){
    cThis = this
    var interval = setInterval(function(){
        if(cThis.attemptConnect(to))
            clearInterval(interval)
    }, retryRate)
}
}