这个是父窗口代码:
<html>
<head>
<script type="text/javascript">
function __change(){
console.log('__change()')
}
</script>
</head>
<body>
<iframe src="A/A.html">1</iframe>
</body>
</html>A.html的代码:
<html>
<head>
<script>
function test(){
console.log('A')
//window.parent.document
// self.parent.__change();
window.parent.__change();
// window.parent.__change()
}
</script>
</head>
<body>
<input type="button" onclick="test()" value="A"/>
</body>
</html> 我在点击按钮A的时候 提示这个错误:
Unsafe JavaScript attempt to access frame with URL file:///U:/js/index.html from frame with URL file:///U:/js/A/A.html. Domains, protocols and ports must match.
A.html:8
Uncaught TypeError: Property '__change' of object [object Window] is not a function 今天整了半天 实在是没办法了javascriptiframefunction
<html>
<head>
<script type="text/javascript">
function __change(){
console.log('__change()')
}
</script>
</head>
<body>
<iframe src="A/A.html">1</iframe>
</body>
</html>A.html的代码:
<html>
<head>
<script>
function test(){
console.log('A')
//window.parent.document
// self.parent.__change();
window.parent.__change();
// window.parent.__change()
}
</script>
</head>
<body>
<input type="button" onclick="test()" value="A"/>
</body>
</html> 我在点击按钮A的时候 提示这个错误:
Unsafe JavaScript attempt to access frame with URL file:///U:/js/index.html from frame with URL file:///U:/js/A/A.html. Domains, protocols and ports must match.
A.html:8
Uncaught TypeError: Property '__change' of object [object Window] is not a function 今天整了半天 实在是没办法了javascriptiframefunction
你把“A.html”放到和父级页面同目录,或你架起web服务再访问 试试