简体   繁体   中英

How to copy and paste text from one page to another page using jquery?

I have to copy repeatedly data (contact info such as name, surname, telephone...) from form A (page 1 in domain x.com) to form B (page 2 in domain y.com)

I have been thinking about creating a chrome extension with the help of jquery to copy the data from form A, and inject it form B...

I have a feeling that this is not the best way to solve this problem...

What do you think is the best way to copy and paste data from pages in different domains?

I'm not a web developer, but I think doing this in pure JavaScript shouldn't be possible (see same origin policy ).

\n

You're probably better off coding something at the server level to handle this, perhaps making a proxy web service on x.com that talks to y.com to do what you need. But the client-side JavaScript running on x.com shouldn't really know about y.com.

EDIT:

Ah now I see; I was thinking that you were coding a Web application for everyone to use. If this is something personal that only you need functionality for, then I might recommend writing a Firefox Greasemonkey script to inject into your x.com code, as Greasemonkey does allow cross-site XMLHttpRequests (Ajax). This would allow you to call a web service running on y.com from your x.com Greasemonkey Javascript. I'm sure you could achieve the same thing using a Chrome extension as you mentioned.

您是否尝试过表单自动填充功能

depends on what your target browsers are. you MAY be able to use some persistent storage api. there are some good wrappers that will abstract the cross browser issues.

but you have size constraints. and may have cross domain issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM