`
luckyjaky
  • 浏览: 111798 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

百度和优酷的搜索体验改善,类似Google Instant搜索

 
阅读更多

转载:http://www.cnblogs.com/samwu/archive/2011/06/29/2093761.html

上次看到国外那谁谁实现了Youtube的Instant搜索,据说花了三小时。

我笑了,我看了那篇文章后,自己花了三小时,实现了百度和优酷的Instant搜索体验。

难点在于,键盘输入的监听。用了JQuery自带的keyup函数,再加JS自带的setTimeout函数,较好地实现了效果。
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
    
< title ></ title >
    
< style  type ="text/css" >
    .hidden
    
{
        display
: none ;
    
}
    .show
    
{
        display
: block ;
         border
: 0 ;
    
}
    #up
    
{
        margin
: -100px 0 0 0 ;
        width
: 1300px ;
        height
: 900px ;
        
        
/*  text-align:center;   */
    
}
    
        #getKey
        
{
            height
:  36px ;
            width
:  379px ;
            font-size
: large ;
            
        
}
    
    
</ style >
    
< script  src ="JS/jquery-1.4.2-vsdoc.js"  type ="text/javascript" ></ script >
    
< script  type ="text/javascript" >
        
var  baidu  =   1 var  youku  =   0 ;
        
var  getKey; 
        
function  gotothere() {
            getKey 
=  $( " #getKey " ).val();
            
if  (getKey  ==   "" ) {
                
// alert("sorry");
                 // $("up").className = "show";
            }
            
else  {
                
if  (baidu  ==   1 ) {
                    $(
" #up " ).attr( " src " " http://www.baidu.com/s?wd= "   +  encodeURI(getKey)  +   " &inputT=624&ie=utf-8 " );
                }
                
else   if  (youku  ==   1 ) {
                    $(
" #up " ).attr( " src " " http://www.soku.com/search_video/q_ "   +  getKey);
                }
            }
        }
        $(
function () {
            $(
" #getKey " ).keyup( function () { // 监听键盘按下事件
                
                
var  timer  =  setTimeout( " gotothere() " 500 ); // 有时候键盘按得太快,监听事件来不及反应,所以用setTimeout函数来延迟
            });


        });

        $(
function () {
            $(
" #baidu " ).click( function () {
                baidu 
=   1 ; youku  =   0 ;
                $(
" #up " ).attr( " src " " http://www.baidu.com/s?wd= "   +  encodeURI(getKey)  +   " &inputT=624&ie=utf-8 " );
            });
            $(
" #youku " ).click( function () {
                youku 
=   1 ; baidu  =   0 ;
                $(
" #up " ).attr( " src " " http://www.soku.com/search_video/q_ "   +  getKey);
            })
        })

    
</ script >
</ head >
< body  style ="overflow-y: hidden;" >
请输入你想要搜索的关键字:
< input  id ="getKey"  type ="text"   />< href ="#"  id ="baidu" > 百度 </ a > &nbsp | &nbsp < href ="#"  id ="youku" > 优酷 </ a >< br  />
< div  style ="overflow:hidden" >< iframe  id ="up"  class ="show"  frameborder ="0"   ></ iframe ></ div >
</ body >
</ html >
分享到:
评论

相关推荐

    instantclient_11_2 64位与32位压缩包下载地址(百度云)

    instantclient_11_2 64位与32位压缩包下载地址(百度云) instantclient_11_2 64位与32位压缩包下载地址(百度云)

    instantsearch.js::high_voltage:一个JavaScript库,用于使用Algolia构建性能和即时搜索体验

    InstantSearch.js是一个JavaScript库,用于构建性能和即时搜索体验。 InstantSearch.js是一个普通JavaScript库,可让您使用的搜索API创建即时搜索结果体验。 它是InstantSearch系列的一部分: InstantSearch.js | | ...

    Instant Client 11.2.0.4.0(Linux)

    Instant Client 11.2.0.4.0(Linux)集成了Linux 64位平台所有的Oracle Instant Client软件包 主要包含以下包: instantclient-basic-linux.x64-11.2.0.4.0.zip instantclient-jdbc-linux.x64-11.2.0.4.0.zip instant...

    最新 instantclient-basic-linux.x64-11.2.0.4.0

    最新 instantclient-basic-linux.x64-11.2.0.4.0最新 instantclient-basic-linux.x64-11.2.0.4.0最新 instantclient-basic-linux.x64-11.2.0.4.0最新 instantclient-basic-linux.x64-11.2.0.4.0最新 instantclient-...

    oracle instant client 32位

    oracle instant client 32位,提供使用方法,链接如下: http://blog.csdn.net/s592652578/article/details/79447996

    instantsearch.js, 用Algolia快速搜索你的应用.zip

    instantsearch.js, 用Algolia快速搜索你的应用 InstantSearch.js 是一个使用 Algolia 构建快速search-as-you-type搜索ui的库。InstantSearch.js 是InstantSearch家族的一部分: InstantSearch.js

    Instant Client 11.2.0.4.0(Windows)

    Instant Client 11.2.0.4.0(Windows).rar 集成了所有的Oracle Instant Client Windows64位的包 包含以下包: instantclient-basic-windows.x64-11.2.0.4.0.zip instantclient-jdbc-windows.x64-11.2.0.4.0.zip ...

    instantclient.zip

    提供oracle客户端windows64客户端文件,PLSQL Developer客户端连接oracle服务端,一般需要在客户端单独安装oracle客户端,可通过下载该文件,配置oracle主目录和oci.dll,免去安装oracle客户端(根据服务端oracle版本...

    instantclient x64和x86

    上传的是一个百度链接,里面有包含windows、linux和aix的三种系统的instantclient x86和x64的包。

    instantclient_12_2.rar

    这是instantclient,这个可以代替oracle客户端的安装,它只是一个文件夹而已,非常轻量级。避免了对电脑运行造成压力。

    react-instantsearch:Swift实现React和React Native应用的快速搜索

    它是InstantSearch系列的一部分: ReactInstantSearch | | | | | 为什么如果要执行以下操作,则应使用React InstantSearch: 利用最佳实践设计搜索体验随意定制组件遵循React原则安装React InstantSearch在npm...

    Oracle Instant Client windows大全

    Oracle Instant Client windows大全 包含32位64位各版本 instantclient-basic-win32-10.1.0.5-20060419 instantclient-basic-win32-10.2.0.5 instantclient-basic-win32-11.1.0.7.0 instantclient-basic-nt-11.2....

    instantclient

    instantclient_11_2

Global site tag (gtag.js) - Google Analytics