0

I know that jQuery doesn't allow multi-domain access into iFrame's. I'm wondering if there is a workaround somehow?

I'm simply trying to set the text inside an input box to a pre-defined username from my DB.

I'm currently getting this error:

Uncaught SecurityError: Blocked a frame with origin "http://domain.com" from accessing a frame with origin "http://track.domain.com". Protocols, domains, and ports must match.

Which is expected as jQuery's documentation clearly states it's not possible using the .contents() function: https://api.jquery.com/contents/

I'm simply curious if there is a workaround to this somehow?

$('#myframe').contents().find('#ext-comp-1001').val('username');

Here is the Fiddle: http://jsfiddle.net/jfreak53/8L2pJ/

jfreak53
  • 2,239
  • 7
  • 37
  • 53

1 Answers1

1

No, you can't access anything or manipulate iFrame content if its from a different domain. This is the purpose of an iFrame. Check This SO question, and this

Also from w3school

Note: Because of security reasons, the contents of a document can be accessed from another document only if the two documents are located in the same domain.

Community
  • 1
  • 1
Manish Kumar
  • 10,214
  • 25
  • 77
  • 147