从书签上传当前 html 页面的内容
将浏览器中查看的当前页面的 html 内容从书签上传到另一台服务器的好方法是什么?
假设这个网址位于需要身份验证的服务器上,所以我想避免在服务器端获取页面,而是想看看是否可以获取内容并直接从浏览器中上传它们。
预先感谢
以利沙的任何建议
What would be a good way to upload the html content of the current page viewed in the browser to another server from a bookmarklet?
Assuming this url is on a server that requires authentication, so I want to avoid fetching the page on the sever side, but rather would like to see if it's possible to get the contents and upload them directly from within the browser.
Thanks in advance for any suggestions
Elisha
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
考虑到您很可能会遇到这样的情况:浏览器中正在查看的页面与您想要将数据发送到的域位于不同的域中,AJAX 请求肯定会失败(由于跨域限制) 。所以做这个服务器端将是你最好的选择。
Considering that you are most probably going to have a situation in which the page being viewed in the browser is on a different domain from the domain you want to send the data to, an AJAX request will definitely fail (due to Cross-Domain restrictions). So doing this server side would be your best bet.
XHR
检索location.href
到字符串中FORM
并将所需的跨站点操作POST
数据发送到服务器location.href
withXHR
into stringFORM
with desired cross-site actionPOST
data to server