Reputation: 841
I am trying to write a website that advertises all of my YouTube videos, with quicklinks to my videos and social media. I do want a search function but I don't want the hastle of messing about with plugins and PHP or Java Servlets or ASP.NET. I have seen you can use Google to do this for you by searching {term} site:{site to search}. How would I go about doing this from JavaScript? I am already storing the user's input from the search box in a variable in JS. How would I go about entering this into Google automatically without any plugins. Purely JavaScript and HTML.
Upvotes: 0
Views: 634
Reputation: 1073968
Just send a form to http://www.google.com/search
with a field called q
with the text of the search. You'll probably want to capture the form's submit
event so you can add the site:xxxx
part before submitting the form; that's the only JavaScript involved, the rest is just a <form>
element.
Of course, using www.google.com
means you'll be sending people to the U.S. site, as opposed to their country-specific site (if any).
Upvotes: 1