Kovács János
Kovács János

Reputation: 103

how to get the html of the content of a cross-domain iframe, or how to get html from another domain by other ways?

I need to replace a cross domain iframe with the html it contains. I can add html and javascript to both domains. I know this should be possible, since youtube seems to do something similar with the comment section. I would just need to do the same. If nothing else works, could this also be done using 'postMessage'? or I could use something like 'document.domain'?

... okay, since the site didnt let me post the question, I have to write something more I guess. I need this because I have to create a script to auto-load youtube comments, since they dont load at ALL on older browsers. I tried using iframes to embed the same thing youtube originally does. But since the content is retrieved from apis.google.com, I had a lot of trouble trying to make it resize itself like it should be. A lot of solutions seem to not work on older browsers, but thats why I need this in the first place. I noticed in firebug how the comments dont seem to open in an iframe, even though I was sure they did. I could even open the frame itself sometime ago, thats how I got the URL the comments are called from. Now only that site's html can be seen there, embedded inside the container. I would be grateful if anyone finally gave a solution.

Upvotes: 1

Views: 429

Answers (1)

Alexei Darmin
Alexei Darmin

Reputation: 2129

You want the YouTube Comments API which returns sets of author, title, and content for a video. I believe you are free to stylize this information however you want.

If you insist on working with iframes then this may be a duplicate of : Cross domain iframe content load detection

Upvotes: 1

Related Questions