开发者

Can I use JavaScript on one page to fill out a form on another server?

Sorry if this is a newbie question, but I've spent several hours on this without success. I've got a PHP script that generates some text I want to submit to an external Web site's form. Is it possible to use JavaS开发者_StackOverflow社区cript code on one page to open a page on another server and then add text to that second page's html form from the code on the first page?


No. Check out this wikipedia article about same origin policy: http://en.wikipedia.org/wiki/Same_origin_policy

EDIT: One thing you can do is submit form data from one site to another. So for example if there is a sign in form on a page. You can't use javascript to populate that form but you could use your page to do a form post from your site to the action of the form on their site. Just make sure that the method(get,post) is the same and the field names are the same. Though keep in mind that a lot of sites do check to make sure that forms are submitted from their own sites but it is possible to try something like this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜