Ext Js 4实现的一个搜索框,调用的是谷歌的api,使用谷歌来搜索
来源:互联网 发布:qq群淘宝客没有订单 编辑:程序博客网 时间:2024/06/04 18:36
1:searchfiled.jsp的内容如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>toolbar4</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><link rel="stylesheet" type="text/css" href="ExtJS4/resources/css/ext-all.css" /> <script type="text/javascript" src="ExtJS4/bootstrap.js"></script> <script type="text/javascript" src="ExtJS4/ext-all.js" ></script> <script type="text/javascript" src="ExtJS4/locale/ext-lang-zh_CN.js"></script> <script type="text/javascript" > Ext.onReady(function() { // A simple subclass of BaseField that creates a HTML5 search field. Redirects to the// searchUrl when the Enter key is pressed.Ext.define('Ext.form.SearchField', { extend: 'Ext.form.field.Base', alias: 'widget.searchfield', inputType: 'search', // Config defining the search URL searchUrl: 'http://www.google.com/search?q={0}', // Add specialkey listener initComponent: function() { this.callParent(); this.on('specialkey', this.checkEnterKey, this); }, // Handle enter key presses, execute the search if the field has a value checkEnterKey: function(field, e) { var value = this.getValue(); if (e.getKey() === e.ENTER && !Ext.isEmpty(value)) { location.href = Ext.String.format(this.searchUrl, value); } }});Ext.create('Ext.form.Panel', { title: 'BaseField Example', bodyPadding: 5, width: 250, // Fields will be arranged vertically, stretched to full width layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'searchfield', fieldLabel: 'Search', name: 'query' }], renderTo: Ext.getBody()});}); </script> </head> <body> </body></html>
2:程序效果
图:在搜索框中输入百度
查找的结果如下图所示:
- Ext Js 4实现的一个搜索框,调用的是谷歌的api,使用谷歌来搜索
- 搜索框的实现JS
- 搜索框的js实现
- Ext 搜索框的制作
- 调用baidu搜索的API实现一个简单的www.baidu.com
- 用Vue.js实现一个简单的搜索框
- 使用google搜索api做自己的搜索服务
- 调用系统的搜索框
- 搜索框即时搜索的实现
- 搜索框的使用
- 使用Vue.js实现表格的排序和搜索功能
- ArcGIS API for javascript中搜索框的使用问题
- js实现ajax搜索的有趣逻辑
- JS--历史搜索记录的实现
- 一个简单的二叉搜索树实现
- 使用Java调用ElasticSearch提供的相关API进行数据搜索完整实例演示
- 使用Java调用ElasticSearch提供的相关API进行数据搜索完整实例演示
- 使用Java调用ElasticSearch提供的相关API进行数据搜索完整实例演示
- 在PowerDesigner12 逆向工程DataBase SQl时出现:unable to list the tables 信息
- IT管理人才必备的十大能力
- 存储过程自动消失
- ADO连接SQL数据库的几种方式
- 使用批处理脚本将log分类
- Ext Js 4实现的一个搜索框,调用的是谷歌的api,使用谷歌来搜索
- Linux的五个查找命令:find,locate,whereis,which,type
- agile manifesto - session1
- phpunit自动安装出现问题以及解决办法
- .net简单的Jquery无刷新分页
- top、ps命令查看当前cpu、mem使用情况
- 转载--你快乐一时,我痛苦一世
- android UI进阶之仿iphone的tab效果
- Java+通过XPath获取XML文件中符合特定条件的节点