8

I have single page application in which I want to apply Google custom search. What my requirement is when I search something then it will show result from each section of the page. I have created anchor tag links whenever click on them it will redirect me to that section of the page.

What I try till now I applied code which comes from while creating search engine here is my code:

(function() {
    var cx = 'xxxxxxxxxxxxxxxx:xxxxxxxxxx'; //my engine id
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
})();

Thanks for the help!

Utkarsh Dubey
  • 703
  • 11
  • 31

0 Answers0