One day I suddenly thought, wouldn't it be wonderful if every time I went to a website, I could immediately call up the information I needed to see? Next I wanted to think about this more deeply, sitting down in a chair with a pencil and not knowing what I was writing. In this case, I still have to deal with coding them.
??My friend opened a small site, which was originally designed by me. This is a good platform to test my ideas. So I wrote the code and uploaded the file. It's really exciting, the program works perfectly, and it also proves that my idea is indeed good.
??I have read some Internet user tendency reports before, and there is a pattern in them that impressed me deeply. It is said that most users will leave the site immediately if they cannot find what they need within three clicks. My code can solve this problem and ensure that users can find the target with just one click of the mouse. In my example, suppose a user logs into Yahoo and searches for Fireplace Accessories (flight equipment accessories). In the results given, when he comes to my friend's site, he will see a screen with words such as "You are searching for Fireplace Accessories". Then he will follow the prompts on the website and go directly to the page he wants to go to.
??The first step you have to do is to create an initial variable in the global.asa file and place it in your Sub Session_onStart() program.
??Sub Session_onStart()
?? Referer = Trim(Request.ServerVariables("HTTP_REFERER"))
??If Referer = "" Then
??Referer = "None"
?? End If
??Session("Referer") = Referer
??End Sub
??Then let's look at how to complete the main functions of the program.
??Because the URL has been encoded, we must first restore the pointing data of the visitor's host into something useful to us. Create an ASP page, call it decode.asp, which is the backbone of our program. The first function is to decode the encoded pointing header. The procedure is a bit long, and very straightforward, without any beating around the bush. If you find it troublesome, you might as well go to the "Internet Worm Training Course" at www.popunet.com to find this article and use the "copy/paste" method.
??The second thing to do in the source code
is to separate the query part from the URL header information-this is what we need.
'Separate the query fields from the pointing URL.
?Function isProduct(pStr)
?? If pStr <> "" And lCase(pStr) <> "none" Then
?? 'Search field backwards
??temp = inStrRev(pStr, "/")
?? 'Get the location of directory separation
?? tempStr = Right(pStr, temp)
?? 'Get the relevant data length
?? temp2 = Len(pStr)
?? 'Get query data rows
??pStr = Mid(pStr, temp, temp2)
?? 'Set the value of the return function
?? isProduct = pStr
??Else
??isProduct = ""
??End If
?End Function
??The next step is to establish clear criteria for the search. To achieve this purpose, create two static spaces "pointers" to find data pointed to by
Function Finder(byRef prodList, byVal refList)
??'fuzzy query
??refList = lCase(refList)
??' Loop through pointers to find matching fields
??For i = 0 To uBound(prodList) - 1
??If inStr(refList, lCase(prodList(i, 0))) Then
??'Find a match
??tHolder = tHolder & "Are You looking For " _
??& "" _
??& prodList(i, 0) & "
??"
??End If
??'Second loop
??Next
??'return result
??Finder = tHolderEnd Function
??Through an inclue, put the decode.asp we prepared into any page that needs this function, and you're done.
The details are as follows:
'If the pointing header is not empty, call this function If lCase(Session("Referer")) <> "none" OR Session("Referer") <> "" Then' Parse the pointing data Response.Write vbCrLf & "
??" _ & Finder(pArray, URLDecode(isProduct(Session("Referer")))) _ & "
??" & vbCrLf
??End If