是否可以使用 JavaScript 创建仅客户端的混搭?
我一整天都在摆弄javasript(jquery)。我想创建一个个人的小混搭,它可以获取一些本地音乐场所的页面内容,重新格式化其数据,然后在单个网页中呈现。
我想我可以聪明一点,将它们加载为 iframe,隐藏 iframe,然后通过 DOM 和 javascript 访问它们的内容。显然,跨站点安全权限也适用于这种方法 - 人们无法更改 iframe 的内容。
我的问题是:是否可以纯粹使用客户端代码创建网站混搭?假设 jsonp / rss api 不是一个选项,并且我希望只使用原始页面内容。我考虑过建立一个 AppEngine 项目来在服务器端处理这个问题,但这对于周末项目来说工作量太大了。
感谢您的任何建议
I have been tinkering with javasript (jquery) all day. I want to create a personal little mashup that grabs the page contents of a few local music venues, reformats their data, and presents in a single webpage.
I thought I could be clever and load them as iframes, hide the iframes, and access their contents through the DOM and javascript. Apparently the cross-site security permission holds true for this approach as well - one cannot alter the contents of an iframe.
My question is: is it possible to create website mashups purely with client side code? Assume jsonp / rss api's are not an option, and I wish to only work with raw page contents. I thought about setting up an AppEngine project to handle this on the serverside, but that is way too much work for a weekend project.
Thank you for any advice
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
并不真地。您可以将混搭代码放在客户端,但要访问所有目标页面,您必须通过自己的服务器将请求代理到它们,以避免同源策略限制。此时,您的情况并不比在服务器端完成更好。
(您可以将其作为非 Web 客户端代码,例如 Firefox 扩展,但这当然会限制您的受众。)
Not really. You could put the mashup code on the client side, but to access all the target pages you would have to proxy requests to them through your own server to avoid the Same-Origin Policy restrictions. At which point you're no better off than if you'd just done it on the server side.
(You could do it as non-web client-side code, eg. a Firefox extension, but of course that limits your audience.)
我不得不研究同一主题。调查结果整理如下。希望它有帮助 -
http://blinkingmind.blogspot.in/2013/02/mashups.html
I've had to research the same topic. findings are collated here. hope it helps -
http://blinkingmind.blogspot.in/2013/02/mashups.html