显示来自其他域的内容
网站为我提供了一个读者来显示我网站上的内容。它们为我提供了我想要显示的内容的 URL。问题是我似乎不可能对其应用样式。
这是一些代码来说明我在做什么。原始域给我这样的 PHP url:
http:// /feed.domain.org/reader.php?date=20110610&type=type&lang=AM
我将此内容加载到我页面上的 iframe 上。然后,为了对其应用样式,我检索它并将其放入 div 中,如下所示:
istyled.innerHTML = iframe.contentWindow.document.body.innerHTML;
内容确实显示在 iframe 中。但 isstyled 是空白的。
许多问题似乎都表明,来自不同域的内容确实会发生这种情况。因为该网站确实向我提供了内容。我该怎么做才能以适合我网站的风格显示该内容?是否有原始域可以在其 Web 服务器上指定的策略,或者是否有特定的方式可以使我可以使用内容来做到这一点?我应该从我的网络服务器上做什么?
A web site makes available to me a reader to show content on my site. They provide me with the URLs for the content I want to display. The problem is that it doesn't seem possible for me to apply styles to it.
Here is some code to illustrate what I am doing. The original domain give me PHP urls like this:
http://feed.domain.org/reader.php?date=20110610&type=type&lang=AM
I load this content on an iframe on my page. Then to apply styles to it, I retrieve it to put it in a div like this:
istyled.innerHTML = iframe.contentWindow.document.body.innerHTML;
The content does show in the iframe. But the istyled is blank.
Many questions seem to say that this does happen with content that comes from a different domain. Since that site does make the content available to me. What could I do to show that content with a style that fits my site? Is there a policy that the original domain could specify on their web server or a specific way that it could make the content available to me to be able to do that? Is there anything that I should do from my web server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您仅从源页面的正文中获取内容,您需要添加回 header 中声明的 CSS 引用,或者只需将 IFRAME src 设置为页面。
You are only taking the content from the body of the source page, you will need to add back in the CSS references declared in the head, or just set the IFRAME src to the page.