Baidu Search drop-down box hint code opensug.js

Source: Internet
Author: User
Tags border color script tag

Opensug Simple Way-convenient to the "Baidu search box (with prompt function)" directly into your page.Add the following code to your Web page to get the Baidu search box with the search box hint feature.
HTML code:
JavaScript code:
tip: JavaScript code should be added to the Web page </body> tag behind.
If you use UTF-8 encoding, you need to include <input name=ie Type=hidden value=utf-8> in your HTML code, and be sure to set the CHARSET=GBK property in the script tag. Otherwise search keywords and prompt words will appear garbled.

• Add Method-Quickly add "Baidu search box hint" function to the "Baidu search box" or other text input box already in the page.
The first step
Add the Baidusug attribute to the <input> tag that needs to add the "Baidu Search box hint" feature. For example:
<input type= "text" name= "word"Baidusug= "1|0" >
When the baidusug=1 is set, the user selects the SUG entry by default to execute the form submission action;
When baidusug=0 is set, the user does not perform a form submission action when the SUG entry is selected.

Step Two
introduce JavaScript files into your Web page:
<script charset= "GBK" src= "Https://cdn.jsdelivr.net/opensug/1.1.1/opensug.js" ></script>

Tips:
If you have multiple input boxes in your Web page that need to add the "Baidu Search box hint" feature, include the Baidusug property for each input box.
JavaScript code is added to the Web page after the </body> tag.
If you use UTF-8 encoding, be sure to set the CHARSET=GBK property in the Script tab, otherwise the search hint Word will be garbled.

=========================================================


Custom Way-Provide "Baidu search box hint" API to create your personalized search box prompt Function!The first step
introduce JavaScript files into your Web page:
<script charset= "GBK" src= "Https://cdn.jsdelivr.net/opensug/1.1.1/opensug.js" ></script>
Step Two
calling the Baidusuggestion.bind () method in a JavaScript program binds the "Baidu Search box hint" feature to the elements on the page.
the specific form of Baidusuggestion.bind () is:

Baidusuggestion.bind (Inputobj|inputid,[params],[confirmcallback]);

Inputobj|inputid:is the ID of the input object or input object that needs to be bound to the search box hint function.
params:the parameters used to bind the search box hint function must be given in JSON form, for example:
Baidusuggestion.bind (' Inputobj ', {"Xoffset"): 0,//Tip box Position lateral offset, unit px "Yoffset": 0,//Tip box Position vertical offset, unit px "width": 350,//Tip box width , Unit px "fontcolor": "#03c",//Hint box text color "Fontcolorhi": "#FFF",///Cue box Highlight selection text color "fontSize": "12px",//Text Size "fontFamily": "Arial", Text font "bordercolor": "#03c",//The border color of the cue box "Bgcolorhi": "#fd0",///Cue box highlight the selected color "Sugsubmit": false///check if the entry in the prompt box submits the form}[, Confirmcallback]);
confirmcallback (TXT):when the user chooses the prompt in the specific option of the callback function, TXT for the user to select the content.

Tips:
JavaScript code is added to the Web page after the </body> tag.
If you use UTF-8 encoding, be sure to set the CHARSET=GBK property in the Script tab, otherwise the search hint Word will be garbled.
JavaScript files should be introduced before the Baidusuggestion.bind () method is called.

Baidu Search drop-down box hint code opensug.js

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.