简体   繁体   English

使用JS在我的网页中加载另一个网站内容

[英]Load another website content in my web page using JS

I have my page, let's call it a.html and I would like to show in this page (for example in a paragraph) the paragraph of another website (let's say www.abc.com/b.html). 我有我的页面,我们称之为a.html,我想在此页面中显示(例如在段落中)另一个网站的段落(比如www.abc.com/b.html)。 Is this possible using javascript? 这可能使用JavaScript吗? I don't want to load all the b page, but just a little part that has a particular id 我不想加载所有的b页面,只是一个具有特定id的小部分

The basic answer is no for security reason, you've to proxy the external page through a server side service. 出于安全原因,基本答案是否定的,您必须通过服务器端服务代理外部页面。

As far as I know there are some recent way to do it, but I'm not sure they would work for any external site neither for any browser. 据我所知,有一些最近的方法,但我不确定它们是否适用于任何外部网站,也不适用于任何浏览器。

From the comment of Gurpreet Singh you can read : http://en.wikipedia.org/wiki/JSONP 根据Gurpreet Singh的评论,您可以阅读: http//en.wikipedia.org/wiki/JSONP

You can try with iframe and some css tricks. 您可以尝试使用iframe和一些CSS技巧。 Just add the iframe to the div where you want to show the other page content. 只需将iframe添加到要显示其他页面内容的div即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM