1: Final effect
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
[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!