简体   繁体   English

动态加载外部网页

[英]Dynamically Load External Webpage

I see this site and many others answering similar questions, but often in ways I fail to understand or just do not make sense. 我看到该网站和许多其他网站都回答了类似的问题,但是常常以我无法理解或没有意义的方式回答。 And often in contradictory ways (maybe the spec keeps changing?). 而且通常是矛盾的方式(也许规格会不断变化吗?)。 And I see posts about how to set up cross domain JavaScript communication, but I do not need to communicate with this external content (and I am still not sure if you must have access to the code-base of both child and parent or not, for these hacks to work). 而且,我看到了有关如何设置跨域JavaScript通信的帖子,但是我不需要与此外部内容进行通信(而且我仍然不确定是否必须访问子代和父代的代码库,让这些骇客正常运作)。

I need to show another person's webpage, on another domain, in a box on my page. 我需要在页面上的框中显示另一个域上另一个人的网页。 SO basically this is like clicking a link, but instead of specifying that the browser should open this in a new tab or a new window, I want the browser to open it in a in-line frame type deal on the current page. 所以基本上,这就像单击链接一样,但是我希望浏览器在当前页面上以内嵌框架类型打开它,而不是指定浏览器应在新选项卡或新窗口中打开它。 So even I know enough about security to know that there are no security/communications issues with this feature. 因此,即使我对安全性也足够了解,也知道此功能没有安全性/通信问题。

But assuming that the browser developers have removed this completely reasonable feature, how do I go about doing this? 但是,假设浏览器开发人员已删除了这一完全合理的功能,我该怎么做呢? I have heard talk about some Json data type thing being allowed, but still have not figured out exactly what that means. 我听说过有关允许使用某些Json数据类型的事情,但是仍然没有弄清楚到底是什么意思。 Can I contact any random external page and get some json summery of the page, or how does this work? 我可以联系任何随机的外部页面并获取页面的json总结,还是如何工作? (I saw an example with Wikipedia, but I was not sure exactly what was being returned, and if any random URL would work just as well). (我在Wikipedia上看到了一个示例,但我不确定返回的内容是否正确,是否有任何随机URL也能正常工作)。

I can use PHP for this, but that is just stupid. 我可以为此使用PHP,但这只是愚蠢的。 I would basically just be setting up a proxy to access content I am randomly banned from because of the programming language I am trying to access it from. 我基本上只是设置一个代理来访问由于我试图从中访问的编程语言而被随机禁止的内容。

You are looking for iFrames . 您正在寻找iFrames Note, however, that there are many security restrictions due to potential cross-site scripting vulnerabilities through improper implementation. 但是请注意,由于实施不当而可能会产生跨站点脚本漏洞,因此存在许多安全限制。

You can change the source of that internal frame by simply editing the source attribute of that iframe 您可以通过简单地编辑该iframe的source属性来更改该内部框架的源

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

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