0

I have a iframe and want to either get some of the HTML from the page in the iframe or the opportunity to change the HTML on the page in the iframe with jQuery.

I use this code to get content from the iframe:

$('iframe#iframeBB').contents().find('table').each(function() {
 var at = $(this).attr('summary');
 if (at == "Latest Data") {
    $('table#main').html($(this).html());
 }
});

This works fine as long as the source for the iframe is at the same domain. My problem is that the source is on another subdomain. I know this is against the Same-Origin Policy, but is there a way to do this?

3 Answers 3

1

If it's a subdomain, you have to let both work on the same tld, by setting document.domain on your pages.

document.domain = "yourdomain.com"
Sign up to request clarification or add additional context in comments.

Comments

0

I think that the only way to do is to get the html output of the page using server side and output it into the iframe.

Comments

0

The document.domain solution didn't worked for me. But I figured out, that you can allow cross domain access by server setting the Access-Control-Allow-Origin header.

You can do this e.g. in the .htaccess file if the server supports it:

  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "http://REQUESTING.domain"
  </IfModule>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.