Move Input Text From Iframe To Main Window
I have an iframe on a page that allows us to upload an image, once it's uploaded it displays the url of the file in a text input field. On the main part of the page, we have our te
Solution 1:
Main.htm
<html><head><script>
getText = function(s)
{
alert(s);
}
</script></head><body><iframesrc="otherFrame.htm"></iframe></body></html>
otherFrame.htm
<html><head><script>
botherParent = function()
{
parent.getText(document.getElementById("textInput").value);
};
window.onload = function()
{
}
</script></head><body><inputtype="text"id="textInput" /><spanonclick="botherParent()">Stuff goes here</span></body></html>
Basically, in the child inline frame, use parent to access the parent's window object. Global variables are stored in window, as are global functions. Because of this, if you define a global variable "foo" in parent, you can access it with parent.foo with your child frame.
Hope that helps!
Solution 2:
Assuming I understand this correctly you want to be able to use javascript to access information in an iFrame from the container page. This is generally regarded as Cross Site Scripting and is not allowed.
Post a Comment for "Move Input Text From Iframe To Main Window"