通过书签发送文本跨域 [英] Sending Text Cross Domain By Bookmarklet

查看:127
本文介绍了通过书签发送文本跨域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用户导航到某个页面,其中包含一些包含有用文本的div。然后单击我的书签并将该div中的文本发送回我的服务器,这与当前域不同。我已经成功地插入jQuery在书签上单击并选择文本。现在我需要找出一种方式来发送文本跨域到我的服务器。我尝试JSONP与jQuery和我的文本太长的url。我的第二个想法是打开一个新窗口,从我的域中加载一个页面,然后以某种方式将选定的文本插入到新窗口中,之后,用户可以单击提交并POST数据到我的服务器。这并不适用于JavaScript跨网站的原因。任何人都有这方面的经验或想法这样做?感谢。

I need a user to navigate to a certain page that has a certain div full of useful text. Then click my bookmarklet and send the text in that div back to my server, which is different from the current domain. I have successfully inserted jQuery on the bookmarklet click and selected the text. Now I need to figure out a way to send that text cross domain to my server. I tried JSONP with jQuery and my text is too long for the url. My second idea was to open up a new window and load a page from my domain, and then somehow insert the selected text into the new window, after which the user could click submit and POST that data to my server. This didn't work for javascript cross-site reasons. Anyone have any experience with this or ideas for doing this? Thanks.

推荐答案

生成表单(使用DOM)和POST数据(您可能希望定位一个iframe,是火和忘记)。

Generate a form (with DOM) and POST the data (you might want to target an iframe, but it will be fire and forget).

这篇关于通过书签发送文本跨域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆