[英]Upload contents of current html page from a bookmarklet
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? 将在浏览器中查看的当前页面的html内容从小书签上载到另一台服务器的好方法是什么?
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 以利沙
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). 考虑到您极有可能会遇到以下情况:浏览器中正在浏览的页面与您要将数据发送到的域位于不同的域,因此AJAX请求肯定会失败(由于跨域限制) 。 So doing this server side would be your best bet.
因此,最好在服务器端进行此操作。
location.href
with XHR
into string XHR
检索location.href
到字符串中 FORM
with desired cross-site action FORM
POST
data to server POST
数据发布到服务器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.