I want to create a google search bar control on the main page of my SharePoint Online website. The bar should search the web through google.

Currently I have found stuff that requires SP Central Admin i.e they are for SP on-premise.

Is there any way of achieving this?

P.S. I do not want to convert my SP Search into a google search.


<form method="get" action="http://www.google.com/search"> <input type="text" name="q" size="100"maxlength="255" value="" style="margin-left:130px; margin-top:45px"/> <input type="submit" value="Google Search" />

Above is my code that works. The only issue I am facing now is that when I use the page in a page viewer web part, it does not open anything as SP gives a security exception. I want it to open the search in a new page.

  • This may help you: stackoverflow.com/questions/13822927/…
    – P S
    Mar 28, 2016 at 17:04
  • If you update is what I think it is, it should be posted as an answer and not an edit Mar 30, 2016 at 12:43
  • i am having issues with it. i cannot make it work inside a page viewer web part as it gives security exceptions in SP.
    – hkhan
    Mar 30, 2016 at 13:00

1 Answer 1


Create a textbox and a button, then use JavaScript to create a function that executes when the button is clicked. The function should take the contents of the textbox and pass them to Google using this syntax.

document.location.href = "https://www.google.com/#q=Query+From+My+Textbox"
  • i have made these changes (See my code in the question). I am using a page viewer content editor to show the page but when i click on the button to search , google does not open up in a new window but in the web part itself. I would like it to open up in a new window.
    – hkhan
    Mar 30, 2016 at 12:35
  • Also it gives a security exception when it tries to open google
    – hkhan
    Mar 30, 2016 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.