・業務システム 設計開発 ・Webサイト設計開発 ・パソコン保守 サポート ・ECSite販売 設計開発 ・VBソフト設計開発

072-807-8850受付:9:00~17:00 休業日:土日祝

スマホ判定  次の文書

参考:http://blog.shibayan.jp/entry/20131209/1386598865

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

CheckBrowserCaps()

End Sub

Function CheckBrowserCaps()

Dim labelText As String = ""
Dim myBrowserCaps As System.Web.HttpBrowserCapabilities = Request.Browser
If (CType(myBrowserCaps, System.Web.Configuration.HttpCapabilitiesBase)).IsMobileDevice Then
labelText = "Browser is a mobile device."
'Response.Redirect("http://www.sskpc.net/sumaho/test01.aspx")
Server.Transfer("test01.aspx", True)
Else
labelText = "Browser is not a mobile device."
End If

Label1.Text = labelText

'// iPhone もしくは、Android と Mobile を同時に含む時はスマートフォン
If Request.UserAgent.Contains("iPhone") Or (Request.UserAgent.Contains("Android") And Request.UserAgent.Contains("Mobile")) Then

Label2.Text = "Browser is a mobile device2."
'Response.Redirect("http://www.sskpc.net/sumaho/test01.aspx")
Server.Transfer("test01.aspx", True)

End If
'

End Function 'CheckBrowserCaps

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = ""
With Request.Browser
s &= "Browser Capabilities" & "<br>"
s &= "Type = " & .Type & "<br>"
s &= "Name = " & .Browser & "<br>"
s &= "Version = " & .Version & "<br>"
s &= "Major Version = " & .MajorVersion & "<br>"
s &= "Minor Version = " & .MinorVersion & "<br>"
s &= "Platform = " & .Platform & "<br>"
s &= "Is Beta = " & .Beta & "<br>"
s &= "Is Crawler = " & .Crawler & "<br>"
s &= "Is AOL = " & .AOL & "<br>"
s &= "Is Win16 = " & .Win16 & "<br>"
s &= "Is Win32 = " & .Win32 & "<br>"
s &= "Supports Frames = " & .Frames & "<br>"
s &= "Supports Tables = " & .Tables & "<br>"
s &= "Supports Cookies = " & .Cookies & "<br>"
s &= "Supports VBScript = " & .VBScript & "<br>"
s &= "Supports JavaScript = " & _
.EcmaScriptVersion.ToString() & "<br>"
s &= "Supports Java Applets = " & .JavaApplets & "<br>"
s &= "Supports ActiveX Controls = " & .ActiveXControls & _
"<br>"
End With
Label3.Text = s
End Sub
End Class

 




← 左の文字をここへ入力後 登録ボタンをクリックしてください

(サイト管理者承認後掲載されます)