The first, i known this question it's duplicated with other questions. But i tried to do following many samples from many issues in stackoverflow but it didn't work. I couldn't call function of main window from iframe but if i use frame tag it's work.
I tried like this.
main window:
<body>
<iframe src='test.html'></iframe>
<script>
var alertFunc = function(){
window.alert("work!");
}
</script>
</body>
test.html
<body>
<input type="button" onclick="window.parent.alertFunc();" value="Test" />
</body>
Error messages from console.
Unsafe JavaScript attempt to access frame with URL file:///C:/.../index.html from frame with URL file:///C:/.../test.html. Domains, protocols and ports must match.
test.html:30
Uncaught TypeError: Cannot call method 'alertFunc' of undefined
And many forms similar to this.
Do you have any ideas? or I did somethings wrong?