简体   繁体   English

重定向到移动网站?

[英]Redirect to Mobile site?

When the user join my site.. if they use mobile.. I want to redirect to the mobile site.. 当用户加入我的网站时..如果他们使用移动..我要重定向到移动网站。

How can I do that with javascript or .net? 我该如何使用javascript或.net?

Put this on your page load: 把它放在页面加载中:

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

If Request.Browser("IsMobileDevice") = "True" Then
Response.Redirect("put url here", True)

End If

End Sub

Hope this will help. 希望这会有所帮助。

Typically, you'd compile a list of user-agent strings for mobile browsers and extract which patterns you want to handle. 通常,您会为移动浏览器编译一个用户代理字符串列表,并提取要处理的模式。 Then in your server code, send a 302 response header OR issue a page with a META refresh to your mobile URL. 然后在您的服务器代码中,发送302响应标头,或向您的移动URL发送一个带有META刷新的页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM