小编给大家分享一下js怎么实现百度搜索提示框,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
创新互联专注于灵石网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供灵石营销型网站建设,灵石网站制作、灵石网页设计、灵石网站官网定制、小程序设计服务,打造灵石网络公司原创品牌,更为您提供灵石网站排名全网营销落地服务。
效果如下所示
话不多说,请看代码:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>百度搜索提示框</title> <style> * { margin: 0;padding: 0; outline: none;} .search201 { width: 650px; margin: 300px auto; font-size: 0; } .sou1 { width: 514px; height: 40px; color: #666; font: 16px Microsoft YaHei; border: 1px solid rgba(170,170,170,.9); border-right: 0; border-radius: 2px 0 0 2px; background: rgba(255,255,255,.9); padding: 0 30px 0 3px; vertical-align: top; display: inline-block; transition: .2s; } .sou2 { width: 100px; height: 42px; font: 16px Microsoft YaHei; color: rgba(255,255,255,.9); background: rgba(0,170,240,1); border: 0; border-left: 1px solid rgba(0,170,240,1); border-radius: 0 2px 2px 0; margin: 0 0 0 -1px; vertical-align: top; transition: .3s; display: inline-block; cursor: pointer; } .sou2:hover { background: rgba(0,140,220,.9); } .sou1:focus { color: #333; border: 1px solid rgba(0,170,240,1); border-right: none; } </style> </head> <body> <div class="search201"> <form action="http://www.baidu.com/baidu" class="search-form" method="" id="search-form"> <input id="ipt1" name="tn" type="hidden" value="baidu" > <input type="text" id="sou1" class="sou1" name="word" maxlength="8048" value="" placeholder="" baiduSug=1 onmouseover="focus()"> <input type="submit" class="sou2" value="百度一下" > </form> </div> <!-- 百度搜索提示 --> <script charset="gbk" src="http://www.baidu.com/js/opensug.js"></script> <!-- we124.com/libs/js/opensug.js(无logo) --> <script> document.getElementById("sou1").focus(); var txtObj = document.getElementById("alertSpan"); //回调函数,用于获取用户当前选择的文字 function show(str){ txtObj.innerHTML = str; } var params = { "XOffset": 0, //提示框位置横向偏移量,单位px "YOffset": 0, //提示框位置纵向偏移量,单位px "width": 204, //提示框宽度,单位px "fontColor": "#666", //提示框文字颜色 "fontColorHI": "#222", //提示框高亮选择时文字颜色 "fontSize": "16px", //文字大小 "fontFamily": "微软雅黑", //文字字体 "borderColor": "#d8d8d8", //提示框的边框颜色 "bgcolorHI": "#e8e8e8", //提示框高亮选择的颜色 "sugSubmit": true, //在选择提示词条是是否提交表单 }; BaiduSuggestion.bind("ipt1",params,show); </script> </body> </html>
以上是“js怎么实现百度搜索提示框”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!
新闻名称:js怎么实现百度搜索提示框
链接分享:https://www.cdcxhl.com/article44/gopphe.html
成都网站建设公司_创新互联,为您提供外贸建站、手机网站建设、云服务器、网站设计公司、网站营销、面包屑导航
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联