One day I had a sudden whim that it would be wonderful if I could I needed to see right away on every website. Next I want to think about this more deeply, sit in a chair and get a pencil, but I don't know what I'm writing. In this way, I still have to deal with the code.
My friend opened a small site, was originally designed by me. This is a good platform to test my ideas. So I wrote the code and uploaded the file. It was so exciting that the procedure worked perfectly, and it proved that I had a good idea indeed.
I've seen some Web user trends reports before, and one of them is very impressive. Said most users will leave the site immediately if they cannot find what they want within three clicks. My code will be able to address this problem, and the insurance user can find the target with just one click of the mouse. In my case, suppose a user is on Yahoo, and the search keyword is fireplace accessories (Flight accessories). In the results given, he came to my friend's site, will see "You are searching for fireplace accessories" and so on the screen. He then follows the prompts on the website and goes directly to the desired page.
The first step you want to make 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 take a look at how to complete the main function of the program.
Because the URL is encoded, the first thing to do is to restore the visitor's host data to something useful to us. Create an ASP page, call it decode.asp, is the backbone of our program. The first function is to decode the encoded pointing head. The program is a bit long, and very direct, there is no beating the bush, if you are too troublesome, as to www.popunet.com "NET Bug Refresher Course" above find this article, with the "Copy/Paste" method.
Source
The second thing to do is to isolate the part of the query from the header of the URL--this is what we need.
'从指向URL中分离查询字段。
Function isProduct(pStr)
If pStr <> "" And lCase(pStr) <> "none" Then
'向后搜索字段
temp = inStrRev(pStr, "/")
'得到目录分离的位置
tempStr = Right(pStr, temp)
'得到有关数据长度
temp2 = Len(pStr)
'得到查询数据行
pStr = Mid(pStr, temp, temp2)
'设定返回功能的值
isProduct = pStr
Else
isProduct = ""
End If
End Function
The next is to establish a clear standard for finding. To achieve this, create two static spaces. Find points to data
Function Finder(byRef prodList, byVal refList)
'模糊查询
refList = lCase(refList)
' 通过指针循环查找匹配字段
For i = 0 To uBound(prodList) - 1
If inStr(refList, lCase(prodList(i, 0))) Then
'找到匹配
tHolder = tHolder & "Are You looking For " _
& "" _
& prodList(i, 0) & "
"
End If
'第二次循环
Next
'返回结果
Finder = tHolderEnd Function
Through a inclue, we put our good decode.asp to any page that needs this function, and we're done.
Specifically as follows:
'如果指向头不为空,调出此功能If lCase(Session("Referer")) <> "none" OR Session("Referer") <> "" Then' 解析指向数据 Response.Write vbCrLf & "
" _ & Finder(pArray, URLDecode(isProduct(Session("Referer")))) _ & "
" & vbCrLf
End If