<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>suggest 自动 提示</title>
<script type="text/javascript" src="http://www.94this.com.cn/myCode/jquery-1.2.1.pack.js"></script>
<script type="text/javascript">
var a_i;
function showGs(event){
if($.browser.msie){
var keyStr = event.keyCode;
}else{
var keyStr = event.which;
}
if(keyStr!=38&&keyStr!=40&&keyStr!=13){
$("#ts").empty();
var vsGsName=escape($("#sGsName").val());
if(vsGsName!=""){
$("#ts").html("正在加载...");
$.post("http://www.94this.com.cn/myCode/jq_suggest/s.asp",{sGsName:vsGsName},function(data){
$("#ts").html(unescape(data));
$("#ts>a").bind("click",function(){
$("#sGsName").val($(this).text());
$("#ts").css("display","none");
});
$("#ts").css("display","block");
//初始化全局变量
a_i=-1;
});
}else{
$("#ts").css("display","none");
}
}else{
//使用键盘上下键选择
if($("#ts").css("display")=="block"){
//得到选择列表的长度
var aLen=$("#ts>a").length;
var _aLen=Number(aLen)-1;
if(keyStr==38){//按下键盘向下方向键
if(a_i>=0&&a_i<=_aLen){
$("#ts>a").get(a_i).style.backgroundColor="";
}
a_i=Number(a_i)-1;
if(a_i<0){
a_i=_aLen;
}
$("#ts>a").get(a_i).style.backgroundColor="#CCCCCC";
}else if(keyStr==40){ //按下键盘的向上方向键
if(a_i>=0&&a_i<=_aLen){
$("#ts>a").get(a_i).style.backgroundColor="";
}
a_i=Number(a_i)+1;
if(a_i>=aLen){
a_i=0;
}
$("#ts>a").get(a_i).style.backgroundColor="#CCCCCC";
}else if(keyStr==13){//按下回车键
var entLiText=$("#ts>a").get(a_i).innerHTML;
$("#sGsName").val(entLiText);
$("#ts").css("display","none");
}
}
}
}
</script>
<style type="text/css">
body{
font-size:12px;
}
table{
position:relative;
}
#ts{
display:none;
position:absolute;
/*left:100px;
top:55px;*/
width:200px;
background-color:#FFFFFF;
border:1px solid #CC9900;
text-align:center;
}
#ts a{
display:block;
height:25px;
line-height:25px;
cursor:pointer;
}
#ts a:hover{
background-color:#CCCCCC
}
</style>
<!--[if IE]>
<style type="text/css">
#ts{
left:100px;
top:55px;
}
</style>
<![endif]-->
</head>
<body>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" style="color:#660000">
<tr>
<td height="30" colspan="3">输入“中”,“国”,“广州”,“公司”看看</td>
</tr>
<tr>
<td width="25%" height="30">请输入名称:</td>
<td width="50%" height="30" align="left">
<input name="sGsName" type="text" id="sGsName" onkeyup="showGs(event)" /><div id="ts"></div>
</td>
<td width="25%"> <a href="http://www.94this.com.cn/article/87.htm">代码下载</a> </td>
</tr>
</table>
</body>
</html>
jQuery.extend({
historyCurrentHash: undefined,
historyCallback: undefined,
historyIframeSrc: undefined,
historyNeedIframe: jQuery.browser.msie && (jQuery.browser.version < 8 || document.documentMode < 8),
historyInit: function(callback, src){
jQuery.historyCallback = callback;
if (src) jQuery.historyIframeSrc = src;
var current_hash = location.hash.replace(/\?.*$/, '');
jQuery.historyCurrentHash = current_hash;
if (jQuery.historyNeedIframe) {
// To stop the callback firing twice during initilization if no hash present
if (jQuery.historyCurrentHash == '') {
jQuery.historyCurrentHash = '#';
}
// add hidden iframe for IE
jQuery("body").prepend('<iframe id="jQuery_history" style="display: none;"'+
' src="javascript:false;"></iframe>'
);
var ihistory = jQuery("#jQuery_history")[0];
var iframe = ihistory.contentWindow.document;
iframe.open();
iframe.close();
iframe.location.hash = current_hash;
}
else if (jQuery.browser.safari) {
// etablish back/forward stacks
jQuery.historyBackStack = [];
jQuery.historyBackStack.length = history.length;
jQuery.historyForwardStack = [];
jQuery.lastHistoryLength = history.length;
jQuery.isFirst = true;
}
if(current_hash)
jQuery.historyCallback(current_hash.replace(/^#/, ''));
setInterval(jQuery.historyCheck, 100);
},
historyAddHistory: function(hash) {
// This makes the looping function do something
jQuery.historyBackStack.push(hash);
jQuery.historyForwardStack.length = 0; // clear forwardStack (true click occured)
this.isFirst = true;
},
historyCheck: function(){
if (jQuery.historyNeedIframe) {
// On IE, check for location.hash of iframe
var ihistory = jQuery("#jQuery_history")[0];
var iframe = ihistory.contentDocument || ihistory.contentWindow.document;
var current_hash = iframe.location.hash.replace(/\?.*$/, '');
if(current_hash != jQuery.historyCurrentHash) {
location.hash = current_hash;
jQuery.historyCurrentHash = current_hash;
jQuery.historyCallback(current_hash.replace(/^#/, ''));
}
} else if (jQuery.browser.safari) {
if(jQuery.lastHistoryLength == history.length && jQuery.historyBackStack.length > jQuery.lastHistoryLength) {
jQuery.historyBackStack.shift();
}
if (!jQuery.dontCheck) {
var historyDelta = history.length - jQuery.historyBackStack.length;
jQuery.lastHistoryLength = history.length;
if (historyDelta) { // back or forward button has been pushed
jQuery.isFirst = false;
if (historyDelta < 0) { // back button has been pushed
// move items to forward stack
for (var i = 0; i < Math.abs(historyDelta); i++) jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop());
} else { // forward button has been pushed
// move items to back stack
for (var i = 0; i < historyDelta; i++) jQuery.historyBackStack.push(jQuery.historyForwardStack.shift());
}
var cachedHash = jQuery.historyBackStack[jQuery.historyBackStack.length - 1];
if (cachedHash != undefined) {
jQuery.historyCurrentHash = location.hash.replace(/\?.*$/, '');
jQuery.historyCallback(cachedHash);
}
} else if (jQuery.historyBackStack[jQuery.historyBackStack.length - 1] == undefined && !jQuery.isFirst) {
// back button has been pushed to beginning and URL already pointed to hash (e.g. a bookmark)
// document.URL doesn't change in Safari
if (location.hash) {
var current_hash = location.hash;
jQuery.historyCallback(location.hash.replace(/^#/, ''));
} else {
var current_hash = '';
jQuery.historyCallback('');
}
jQuery.isFirst = true;
}
}
} else {
// otherwise, check for location.hash
var current_hash = location.hash.replace(/\?.*$/, '');
if(current_hash != jQuery.historyCurrentHash) {
jQuery.historyCurrentHash = current_hash;
jQuery.historyCallback(current_hash.replace(/^#/, ''));
}
}
},
historyLoad: function(hash){
var newhash;
hash = decodeURIComponent(hash.replace(/\?.*$/, ''));
if (jQuery.browser.safari) {
newhash = hash;
}
else {
newhash = '#' + hash;
location.hash = newhash;
}
jQuery.historyCurrentHash = newhash;
if (jQuery.historyNeedIframe) {
var ihistory = jQuery("#jQuery_history")[0];
var iframe = ihistory.contentWindow.document;
iframe.open();
iframe.close();
iframe.location.hash = newhash;
jQuery.lastHistoryLength = history.length;
jQuery.historyCallback(hash);
}
else if (jQuery.browser.safari) {
jQuery.dontCheck = true;
// Manually keep track of the history values for Safari
this.historyAddHistory(hash);
// Wait a while before allowing checking so that Safari has time to update the "history" object
// correctly (otherwise the check loop would detect a false change in hash).
var fn = function() {jQuery.dontCheck = false;};
window.setTimeout(fn, 200);
jQuery.historyCallback(hash);
// N.B. "location.hash=" must be the last line of code for Safari as execution stops afterwards.
// By explicitly using the "location.hash" command (instead of using a variable set to "location.hash") the
// URL in the browser and the "history" object are both updated correctly.
location.hash = newhash;
}
else {
jQuery.historyCallback(hash);
}
}
});
function pageload(hash) {
// alert("pageload: " + hash);
// hash doesn't contain the first # character.
// 根據傳回的 hash(錨點),AJAX 置換顯示的內容
if(hash) {
// restore ajax loaded state重新讀取指定頁面
if($.browser.msie) {
// jquery's $.load() function does't work when hash include special characters like aao.
hash = encodeURIComponent(hash);
}
$("#load").load(hash + ".html");
} else {
// start page 如果沒有回傳值,代表已經回到 AJAX 的初始狀態頁,清空顯示的內容
$("#load").empty();
}
}
$(document).ready(function(){
// Initialize history plugin.The callback is called at once by present location.hash.
// 初始化 history plugin,並設定回傳使用的函數
$.historyInit(pageload, "jquery_history.html");
// set onlick event for buttons 設定觸發寫入歷史紀錄條件的按鈕事件
$("a[rel='history']").click(function(){
// 取得超連結的錨點
var hash = this.href;
hash = hash.replace(/^.*#/, '');
// moves to a new page.
// pageload is called at once.
// hash don't contain "#", "?"
// 點選 AJAX 頁面時,紀錄位置於瀏覽器的歷史紀錄中
$.historyLoad(hash);
return false;
});
});
</script>
</head>
<body>
<h1>jquery history plugin</h1>
This plugin helps you make your Ajax-driven page available for "Go Back" button and "bookmark" of browser.<br>
source: <a href="jquery.history.js">jquery.history.js</a> (Last Update: 2009/10/14)<br>
<br>
<a href="history/rbbs.cgi">jquery history bbs</a><br>
<br>
Work on IE8, FireFox 4.0, Opera9, Safari 4.0, Chrome 2.0. <br>
<br>
<br>
[<a href="jquery_history_xhtml.html">xhtml 1.0 test</a>]
[<a href="jquery_history_ie7.html">IE7 compatible mode test</a>]
<br>
<hr>
首先建立簡單的 AJAX 超連結:
Ajax load<br>
<a href="#1" rel="history">load 1</a><br>
<a href="#2" rel="history">load 2</a><br>
<a href="#3" rel="history">load 3</a><br>
<a href="#aao" rel="history">load aao</a><br>
<br>
<hr>
Loaded html:<br>
<div id="load"></div>
<hr>
<h1>update history</h1>
<br>
Safari support & bug fix on IE6 was offered by Lincoln Cooper. Thanks.
<br>
<br>
Fix IE6 problem was offered by Anton. Thanks.
<br>
<br>
Support IE8 was offered by Yohann MARTEL. Thanks.
<br>
<br>
2009/06/06<br>
When hash contains "?" char, there was a problem in the interchangeability between browsers.
<a href="http://www.mikage.to/jquery/jquery_history.html#1?aaa">http://www.mikage.to/jquery/jquery_history.html#1?aaa</a> didn't work on IE.
Plugin remove string that following "?" now.<br>
This problem was reported by Chris Pall. Thanks.
<br>
<br>
2009/06/10<br>
History plugin work with "jQuery.noConflict();". NoConflict version works with another framework (prototype, etc...). sample is <a href="jquery_history_noc.html">here</a>.<br>
This problem was reported by Mat Ellis. Thanks.
<br>
<br>
2009/06/21<br>
Iframe src problem patch offered by Francesco Sullo. Thanks.<br>
When hash include special characters like aao, plugin does't work correctly on Firefox/IE. This problem was reported by Peter Nguyen. Thanks.<br>
<br>
<br>
2009/06/22<br>
Chrome/Safari patch offered by Peter Nguyen. Thanks.
<br>
<br>
2009/06/25<br>
Chrome/Safari patch offered by Peter Nguyen. Thanks.
<br>
<br>
2009/09/13<br>
I am sorry for being not able to reply though a lot of mails are gotten. <br>
The BBS was set up. <a href="history/rbbs.cgi">jquery history bbs</a><br>
<br>
In IE8, the plugin breaks when using a DOCTYPE of XHTML 1.0.<br>
This problem patch offered by Jonathan. Thanks.<br>
<a href="jquery_history_ie8.html">This version is here.</a> But this version is not work with HTML 4.0 on IE8.<br>
<br>
<br>
2009/10/13<br>
<a href="http://wp.serpere.info/archives/783">IE8 patch</a> offered by serpere. Thanks.<br>
Now history plugin works at all mode in IE8.
<br>
<br>
2009/10/14<br>
<a href="http://www.mikage.to/jquery/history/rbbs.cgi?id=RA12554211511102038965&focus=1">IE6 secure alert patch</a> offered by Øyvind Smestad. Thanks.<br>
<br>
<br>
<br>
<hr>
<a href="/">mikage's page. (Japanese)</a> > <a href="/jquery/">jquery dev memo. (Japanese)</a>
</body>
分享到:
相关推荐
在IT领域,"Suggest自动提示功能"是一种常见的交互设计技术,主要应用于各种输入框,如搜索引擎、文本编辑器或在线表单等。这个功能旨在提高用户体验,通过预测和建议用户可能想要输入的内容来加快输入速度,从而...
《Kissy Suggest 自动提示实现详解》 在IT领域,自动提示功能是提升用户体验、提高工作效率的重要手段,尤其在编程、搜索等场景下。Kissy Suggest 是一个基于 JavaScript 的开源库,专为实现自动提示功能而设计。...
在本篇博客“jQuery学习记录----仿GoogleSuggest自动提示(八)”中,作者分享了如何使用jQuery实现一个类似于Google搜索框中的自动提示功能。这个功能是许多网站上常见的用户体验提升工具,它允许用户在输入关键词...
JavaScript Suggest自动补全的输入框下拉提示类是一种常见的前端开发技术,广泛应用于各种Web应用,如搜索引擎、表单输入、代码编辑器等。它为用户提供了一个方便、高效的交互体验,通过预测用户可能要输入的内容,...
在提供的文件“31_实现仿GoogleSuggest自动补全的功能.avi”中,可能包含了实现这一功能的具体步骤和示例代码。通过观看这个视频教程,你可以学习到如何从头构建这样的功能,包括前端交互逻辑、后端接口设计及其实现...
jQuery Suggest插件就是这样一个工具,它为网页中的输入框提供了自动补全功能,使得用户在输入时能快速找到并选择所需的内容,大大提高了输入效率。本篇文章将深入探讨jQuery Suggest插件的使用方法、原理以及如何...
【压缩包子文件的文件名称列表】"GoogleSuggest自动补全"可能包含了实现这一功能的所有文件,包括HTML文件用于构建用户界面,JavaScript文件用于处理AJAX请求和动态渲染建议,以及可能的CSS文件来美化界面样式。...
文本框Input文字自动完成Suggest提示插件,一款Suggest搜索提示插件,暗藏有淘宝首页、有啊首页、Google搜索首页、来点广告搜索的众多下拉提示,实际上演示效果与其真实网站上的相关无几,使用了Yahoo网站的一个搜索...
完整的词汇" href="javascript:void(0)">用户输入部分 自动提示部分 <!-- 更多li --> ``` `autocomplete="off"`属性用于关闭浏览器默认的自动填充功能。`data-*`属性是HTML5引入的自定义数据属性,便于...
本文将重点介绍一种强大的自动补全提示组件——Kissy Suggest,它是一个基于JavaScript的开源工具,适用于各种前端项目。 Kissy Suggest是Kissy框架的一部分,Kissy是一个轻量级的前端JavaScript库,旨在简化Web...
Suggest(建议或自动补全)是搜索引擎的一种特性,它根据用户输入的部分文本,快速返回可能的完整查询建议。这一功能广泛应用于搜索框中,能够帮助用户更快找到他们想要的信息,同时也提高了搜索的精确性。 在...
【标题】"仿Google Suggest提示效果"是一个关于在网页中实现类似Google搜索框自动提示功能的技术分享。这种功能在现代网页应用中非常常见,它能够提升用户体验,帮助用户更快地找到他们想要输入的关键词。 【描述】...
标题中的“suggest 仿google提示”指的是创建一个类似于Google搜索框自动补全的功能。这个功能在用户输入查询词时,会根据已有的数据提供相关的建议,以提高搜索效率和用户体验。这种技术通常被称为自动完成功能或者...
该脚本功能很强大,类似google的自动完成。 使用了cache 功能,当敲入的字符数可以在cache中查到时,将不会向服务器发送请求。减轻服务器压力 使用空格匹配,一个空格字符相当于1个或多个字符(串),可以自己写简单...
search-suggest 可快速创建你的搜索提示功能 /搜索自动补全功能。功能说明把句子分词后缓存转换成拼音缓存把句子分词后缓存当你输入英文 或者中文的时候,可以从缓存里获取匹配值返回使用 标签:search
id:自动编号 keyword:关键字 seachtimes:被搜索次数 matchnum:匹配的文章数目(关于这个方面想了蛮久,如何取得文章数呢,不能是搜索时动态产生,不然在偌大数据库中查询费时费力.那么必然是在后台某个时候去其他的...
标签“源码”和“工具”提示我们,这篇博客可能探讨了有关自动补全功能的底层代码实现,或者是使用某种工具或框架来构建这样的功能。源码分析通常涉及理解代码结构、算法和数据结构,以揭示其工作原理。而“工具”...
Suggest组件则是Kissy中用于实现自动提示、补全功能的部分,常见于搜索框或输入框,能够提升用户输入体验。 在描述中提到的“博文链接:https://leon1509.iteye.com/blog/436009”,这可能是一个关于Kissy Suggest...