Multiple Google CSE (Custom Search Engine) Boxes on Same Page

前端 未结 2 573
忘掉有多难
忘掉有多难 2021-01-20 06:50

I am trying to implement two (different) Google CSE search boxes on the same page. The issue is that only the first instance works properly. For example, a sitewide search b

2条回答
  •  萌比男神i
    2021-01-20 07:15

    From: http://www.google.com/cse/docs/cref.html

    The parameter in /coop/cse/brand named "form" outputs the first getElementById in the code. As such, using http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en will create a cse-search-box-targetted code, whilst giving it box2 will trigger on a different ID. The keyword searchbox_demo is reserved.

    Give it a go if you'd like to: http://jsfiddle.net/JTV6f/1/ . Considering what you are doing, however, if I were you, I'd switch to either the V1 or V2 APIs.

提交回复
热议问题