0

I have this iFrame in my parent window...

<iFrame src="http://theirdomain.com" id="Post_iFrame"></iFrame> 

Then I have the jquery script...

$(document).ready(function(){ $(document).on("click","#transfer",function() { var $currentIFrame = $('#Post_iFrame'); $currentIFrame.contents().find("body #Name1").val("My new value"); }); }); 

I am trying to find the text field #Name1 in the iframe and populate this input with My new value but nothing is happening. Any suggestions?

4
  • <label for="Name1"> <span class="isRequired">*</span>First Name:</label><input type="text" id="Name1" name="Name1" size="25" maxlength="25" /> Commented Jun 22, 2012 at 20:10
  • iframe and page on same domain? Commented Jun 22, 2012 at 20:10
  • cross domain security issue then Commented Jun 22, 2012 at 20:11
  • is their anyway to bypass that? Commented Jun 22, 2012 at 20:12

1 Answer 1

2

Following your comment:

no its a different domain

You need to have a look at Same Origin Policy:

In computing, the same origin policy is an important security concept for a number of browser-side programming languages, such as JavaScript. The policy permits scripts running on pages originating from the same site to access each other's methods and properties with no specific restrictions, but prevents access to most methods and properties across pages on different sites.

For you to be able to get data, it has to be:

Same protocol and host

You need to implement JSONP to workaround it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.