Detailed example of implementing search toolbar through javascript

巴扎黑
Release: 2017-05-22 11:46:09
Original
1534 people have browsed it

1: Final effect
Detailed example of implementing search toolbar through javascript

2: Principle

If you search for "China" in Yahoo, Then you will get a string of addresses like this in the browser's address bar: http://search.cn.yahoo.com/search?ei=gbk&fr=fp-tab-web-ycn&meta=vl%
3Dlang_zh-CN%26vl %3Dlang_zh-TW&pid=ysearch&source=ysearch_www_hp_button
&p=%D6%D0%B9%FA&Submit=
It looks a bit confusing, please simplify it: http://search.cn.yahoo.com/search?&p= %D6%D0%B9%FA
This is the key. &p=%D6%D0%B9%FA is the keyword parameter of the search, and %D6%D0%B9%FA is the
of "China" Url encoding. OK, as long as we can construct such encoding.

Three: URL encoding
The encodeURIComponent() function of JavaScript can complete the encoding work.
For example, in the above example, we can use "http://search.cn.yahoo.com/search?&p="+encodeURIComponent("China"); to complete.

Four: Code
(Click the plus sign to expand)

The code is as follows:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Search.aspx.cs" Inherits="Search" %>    Search  



Search



Key Web Mp3 Image


Home
Copy after login

[Related recommendations]

1.Javascript free video tutorial

2.Detailed introduction to multi-valued motion of JavaScript motion framework (4)

3.JavaScript motion framework Sharing sample codes for the arbitrary movement of multiple objects (3)

4.How to solve the anti-shake problem and suspended couplets in JavaScript motion framework (2)

5.How to solve the problem of positive and negative speed rounding in JavaScript motion framework (1)

The above is the detailed content of Detailed example of implementing search toolbar through javascript. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!