Using JQuery to redirect to a third party page and prefill form values
When clicked on a link on my web page, I want to redirect to third party web page (like google) and prefill the search window with my query and simulate clicks.
Is it p开发者_开发问答ossible to do with just jquery?
You don't need any JavaScript for that (that is, when you want to simulate the click, too).
I assume, you want to have something like a custom search box. Then open up Google's front page and look at the source code (which is quite a mess, I suggest Firebug for this).
Search the HTML <form>
that is responsible for the form field and all containing <input>
fields. If the <form>
element has this attribute: method="GET"
(or no method
at all), you can just combine all other inputs but q
in the URL (the action
attribute) of the form by collapsing them like "a=b&c=d"
.
Then write your own form on your website, or even just a simple link (since links are nothing more than get requests to other pages, in this case you will also have to add the q
, too).
Tadaa! Your own submit form to Google.
精彩评论