发布于 2017-07-06 03:13:32 | 91 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Javascript教程,程序狗速度看过来!

JavaScript客户端脚本语言

Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题,为客户提供更流畅的浏览效果。


本文主要分享了js实现百度搜索提示框的示例代码,具有很好的参考价值,下面跟着小编一起来看下吧

效果如下所示

话不多说,请看代码:


<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>百度搜索提示框</title>
<style>
* { margin: 0;padding: 0; outline: none;}
.search101 {
 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="search101">
 <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> 

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持phperz!



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务