How to call a javascript function from one frame to another in Chrome/Webkit
Posted
by bambax
on Stack Overflow
See other posts from Stack Overflow
or by bambax
Published on 2010-04-03T08:56:46Z
Indexed on
2010/04/03
9:03 UTC
Read the original article
Hit count: 283
I have developped an application that has a list of items in one frame; when one clicks on an item it does something in another frame (loads an image).
This used to work fine in all browsers, including Chrome 3; now it still works fine in FF but in recent versions of Chrome (I believe since 4) it throws this error:
Unsafe JavaScript attempt to access frame with URL (...) from frame with URL (...). Domains, protocols and ports must match.
This is obviously a security "feature" but is it possible to get around it?
Here is a simple test:
index.html:
<html>
<frameset>
<frame src="left.html" name="left"/>
<frame src="right.html" name="right"/>
</frameset>
</html>
left.html:
<html>
<body>
<a href="javascript:parent.right.test('hello');">click me</a>
</body>
</html>
right.html:
<html>
<body>
<script>
function test(msg) {
alert(msg);
}
</script>
</body>
</html>
The above works in FF 3.6 and Chrome 3 but in Chrome 5 it throws the above error...
© Stack Overflow or respective owner