ব্রাউজার, ব্রাউজার সংস্করণ, ওএস এবং ওএস সংস্করণ সনাক্ত করতে আমি এএসপি কোডে একটি স্ক্রিপ্ট তৈরি করেছি। আমার এএসপিতে এটি করার কারণ হ'ল আমি লগ-ডাটাবেজে ডেটা সঞ্চয় করতে চাই। সুতরাং আমি ব্রাউজার সার্ভারসাইড সনাক্ত করতে হয়েছিল।
কোডটি এখানে:
on error resume next
ua = lcase(Request.ServerVariables("HTTP_USER_AGENT"))
moz = instr(ua,"mozilla")
ffx = instr(ua,"firefox")
saf = instr(ua,"safari")
crm = instr(ua,"chrome")
max = instr(ua,"maxthon")
opr = instr(ua,"opera")
ie4 = instr(ua,"msie 4")
ie5 = instr(ua,"msie 5")
ie6 = instr(ua,"msie 6")
ie7 = instr(ua,"msie 7")
ie8 = instr(ua,"trident/4.0")
ie9 = instr(ua,"trident/5.0")
if moz>0 then
BrowserType = "Mozilla"
BrVer = mid(ua,moz+8,(instr(moz,ua," ")-(moz+8)))
end if
if ffx>0 then
BrowserType = "FireFox"
BrVer = mid(ua,ffx+8)
end if
if saf>0 then
BrowserType = "Safari"
BrVerPlass = instr(ua,"version")
BrVer = mid(ua,BrVerPlass+8,(instr(BrVerPlass,ua," ")-(BrVerPlass+8)))
end if
if crm>0 then
BrowserType = "Chrome"
BrVer = mid(ua,crm+7,(instr(crm,ua," ")-(crm+7)))
end if
if max>0 then
BrowserType = "Maxthon"
BrVer = mid(ua,max+8,(instr(max,ua," ")-(max+8)))
end if
if opr>0 then
BrowserType = "Opera"
BrVerPlass = instr(ua,"presto")
BrVer = mid(ua,BrVerPlass+7,(instr(BrVerPlass,ua," ")-(BrVerPlass+7)))
end if
if ie4>0 then
BrowserType = "Internet Explorer"
BrVer = "4"
end if
if ie5>0 then
BrowserType = "Internet Explorer"
BrVer = "5"
end if
if ie6>0 then
BrowserType = "Internet Explorer"
BrVer = "6"
end if
if ie7>0 then
BrowserType = "Internet Explorer"
BrVer = "7"
end if
if ie8>0 then
BrowserType = "Internet Explorer"
BrVer = "8"
if ie7>0 then BrVer = BrVer & " (in IE7 compability mode)"
end if
if ie9>0 then
BrowserType = "Internet Explorer"
BrVer = "9"
if ie7>0 then BrVer = BrVer & " (in IE7 compability mode)"
if ie8>0 then BrVer = BrVer & " (in IE8 compability mode)"
end if
OSSel = mid(ua,instr(ua,"(")+1,(instr(ua,";")-instr(ua,"("))-1)
OSver = mid(ua,instr(ua,";")+1,(instr(ua,")")-instr(ua,";"))-1)
if BrowserType = "Internet Explorer" then
OSStart = instr(ua,";")
OSStart = instr(OSStart+1,ua,";")
OSStopp = instr(OSStart+1,ua,";")
OSsel = mid(ua,OSStart+2,(OSStopp-OSStart)-2)
end if
Select case OSsel
case "windows nt 6.1"
OS = "Windows"
OSver = "7"
case "windows nt 6.0"
OS = "Windows"
OSver = "Vista"
case "windows nt 5.2"
OS = "Windows"
OSver = "Srv 2003 / XP x64"
case "windows nt 5.1"
OS = "Windows"
OSver = "XP"
case else
OS = OSSel
End select
Response.write "<br>" & ua & "<br>" & BrowserType & "<br>" & BrVer & "<br>" & OS & "<br>" & OSver & "<br>"
'Use the variables here for whatever you need........