Quote:
Originally Posted by Yeroon
Then you can ask for url, call events etc.
You can only access properties and events of iframe pages if they are on the same domain.
|
If the website the user is on is owned by the same guy who owns the first domain, he could just set up message listeners and send messages (using postMessage) to each other.
Example:
http://example.a/ sends:
Code:
SomeIframe.postMessage(
JSON.stringify({
"request-var": "location.href"
}),'http://example.b');
http://example.b/ responds:
Code:
window.onmessage = function(e) {
if (e.origin == 'http://example.a') {
var requestVar = JSON.parse(e.data)['request-var'];
e.source.postMessage(JSON.stringify(window[requestVar]), e.origin);
}
}
The code either requires a Gecko-based browser (which includes the JSON object as of 1.9.1, ie. Firefox 3.1+) or json2.js to have been loaded beforehand.
postMessage will only work in Safari 3.1.2+, Firefox 3+, and IE8 beta 2.