"Baidu search box hint" code

Source: Internet
Author: User

How to use:

Baidu offers 2 ways to customize calls
Method One:

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|2″>
When the baidusug=1 is set, the user selects the SUG entry by default to execute the form submission action;
When baidusug=2 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= "Http://www.baidu.com/js/opensug.js" ></script>

By Gonten testing, the method is very simple and easy to use, the hint drop-down box can be adjusted automatically according to the input box width.

See Effect: http://www.baidu.com/search/sug/demo1.html

Method Two:

The first step
Introduce JavaScript files into your Web page:

<script charset= "GBK" src= "Http://www.baidu.com/js/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:
{
"Xoffset": 0,//Tip box Position horizontal offset, unit px
"Yoffset": 0,//Tip box Position vertical offset, unit px
"width": 350,//Cue box width, unit px
"FontColor": "#03c",//Cue box text color
"Fontcolorhi": "#FFF",//Cue box highlight selection text color
"FontSize": "12px",//Text size
"FontFamily": "Song Body",//Text font
"BorderColor": "#03c",//Border color of the cue box
"Bgcolorhi": "#fd0 ″,//Cue box highlight selected color
"Sugsubmit": false//To submit the form when the entry in the Prompt box is selected
}
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.
JavaScript files should be introduced before the Baidusuggestion.bind () method is called.
View Sample Effects

In general the use of the first method is enough, the use of more convenient, if you will use the second kind is also good. In the bottom right corner of the search prompt is a "Baidu search box Prompt" text, and there is a link to Baidu. Want to get rid of? Not difficult, gonten for everyone to find the shielding method. Just add it on the input box:

<style type= "Text/css" >
<!–
. Bdsug_copy{display:none}
–>
</style>

You can also add it to the

"Baidu search box hint" code

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.