
November 7th, 2012, 05:29 PM
|
 |
Contributing User
|
|
|
|
Quote: | Originally Posted by Kravvitz The OP (original poster) is korssane. You're responding to gsharp who is saying that it's simpler to keep the array in the parent document. |
Yeah, your right Kravvitz... my fault korssane. I was working on something and trying to respond, at the same time. The point that I was making, was that the OP... could have found the solution by searching for "iframe communication"; which would have given a "remote control" iframe/parent.document communication and several other examples, such as: HTML5 postMessage - for a cross domain solution.
At any rate... korssane, a basic example would be something like gsharp and Kravvitz is talking about; something such as:
Parent Document
Code:
<script>
function getArray(myArray)
{
alert(myArray);
}
</script>
<iframe src="framed_page.html"></iframe>
framed_page.html
Code:
<script>
var demoArray = ["Hello korssane!"];
</script>
<a href="#" onclick="parent.getArray(demoArray[0]);return false">Click Me</a>
In the basic example above; the document(s) must remain under the same domain, because of the Same-Origin (domain security) policy (most modern browsers implore). If you need a cross domain approach; you might want to look into "HTML5 postMessage", as I briefly mentioned above.
Last edited by web_loone08 : November 7th, 2012 at 07:10 PM.
|