HTML5 页面请求
我一直在寻找一种简单地使用 HTML5 请求网页的方法。具体来说,我想向不同的站点发出 HTTP(S) 请求。由于明显的安全原因,这听起来似乎一开始是不可能的,但我被告知这是可能的(也许使用 WebSockets?)。
我不想使用 iframe,除非有一种方法可以使被请求的外部站点不知道它是通过 iframe 请求的。
我一直很难找到这些信息。我想做的就是加载一个网页并显示它。
有人可以分享一些代码或一些建议吗?
谢谢。
I have been searching around for a way to simply request webpages with HTML5. Specifically, I want to do an HTTP(S) request to a different site. It sounds like this is not possible at first due to obvious security reasons, but I have been told this is possible (maybe with WebSockets?).
I don't want to use iframes, unless there is a way to make it so the external site being requested does not know that it is being requested through an iframe.
I've been having a really difficult time finding this information. All I want to do is load a webpage, and display it.
Does anyone have some code they could share, or some suggestions?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您正试图规避同源政策。不要这样做:)
如果这只是您想要的请求(而不是其他),有很多方法可以做到这一点,即使用 JavaScript 中的
new Image
或iframe< /代码>。通过检查
top.location.href != window.location.href
,网站将知道它位于iframe
中。Sounds like you are trying to to circumvent Same Origin Policy. Don't do that :)
If it is just the request you want (and nothing else), there are a number of ways to do it, namely with
new Image
in JavaScript oriframe
. The site will know it is in aniframe
by checkingtop.location.href != window.location.href
.通过代理汇集所有请求可能是一个解决方案 - 客户端仅寻址代理,而要检索的实际 url 将是查询字符串参数。
最好的问候,卡斯滕
funneling all your requests through a proxy might be a solution - the client addresses only the proxy and the actual url to retrieve would be a query string parameter.
best regards, carsten