sticksu
sticksu

Reputation: 3738

Main web document vs iframe script

So i have this problem: I have an input in an iframe with some text in it and another input outside the iframe,in the page body which is empty. What I need is to copy the text in the iframe input to the other input. How can I do this?

Example code:

<html>
  <head>
  </head>
  <body>
    <input id="outside-input" type="text"/>
    <iframe>
      <input id="inside-input" type="text"/>
    </iframe>
  </body>
</html>

I don't see how this would be rellevant but the iframe is in fact the Wordpress media upload pop-up.

Upvotes: 0

Views: 56

Answers (2)

A. Wolff
A. Wolff

Reputation: 74410

If iframe is on same domain, you can access its content like this:

$('#outside-input').val($("iFrame").contents().find("#inside-input").val());

Upvotes: 2

webnoob
webnoob

Reputation: 15934

AFAIK you cannot access the content of the IFrame from your main page directly using JQuery / other JS.

Upvotes: 0

Related Questions