vb Get CSS file depending on browser

Public Function CSS()
	'determines which additional style sheet to call, depending on the user's browser - which allows for browser specific styles
	Dim strCSS
	Dim strMedia
	Dim strUserAgent
	Dim strReturn
	
	strUserAgent = Request.ServerVariables("HTTP_USER_AGENT")
	strMedia = "screen"
	strCSS = ""

	If InStr(strUserAgent,"MSIE 6.0")>0 Then
		strCSS = "ie6.css"
	ElseIf InStr(strUserAgent,"MSIE 7.0")>0 Then
		strCSS = "ie7.css"
	ElseIf InStr(strUserAgent,"MSIE 8.0")>0 Then
		strCSS = "ie8.css"
	ElseIf InStr(strUserAgent,"Chrome")>0 Then
		strCSS = "chrome.css"	
	ElseIf InStr(strUserAgent,"Safari")>0 Then
		strCSS = "safari.css"
	ElseIf InStr(strUserAgent,"Opera")>0 Then
		strCSS = "opera.css"
	ElseIf InStr(strUserAgent,"Firefox")>0 Then
		strCSS = "firefox.css"
	End If

	If Application("Debug") = 1 Then
		Response.Write("<!--User Agent:" & Request.ServerVariables("HTTP_USER_AGENT") & "-->" & vbcrlf)
	End If

	If strCSS <> "" Then
		strReturn = ("<link href=""" & Application("CDN") & "css/" & strCSS & """ rel=""stylesheet"" type=""text/css"" media=""" & strMedia & """ />")
	End If
	
	CSS = strReturn
End Function
Writes out a link to a browser specific CSS file depending on which browser the visitor is using - as used within slickcms

Updated: Saturday 9th October 2010, 00:15pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.