移动设备加载时网站重定向
我希望当用户尝试使用移动设备加载我的网页时,将其定向到我的移动实现。有没有可以用于 iPhone、Android 甚至三星的脚本?我在互联网上找到了我的脚本,但我无法弄清楚哪个有效,哪个无效
I want the user to be directed to my mobile implementation when he tries to load my webpage using a mobile device. Is there any script that I can use for iphone, android and maybe samsung? I found my scripts in the internet but I cannot figure out which one is working and which one is not
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要 JavaScript 重定向,您可以检查浏览器的用户代理并采取相应的操作。这可能被证明是不准确的,因为用户代理可以被修改(通常是这种情况)。下面的示例检查设备是否是 iPad 并将浏览器路由到另一个位置。您将需要找出您正在与 iPhone、Android 或任何其他设备打交道的用户代理,并实现此逻辑。希望这有帮助。
If you are wanting a javascript redirect, you can examine the user agent of the browser and act accordingly. This can prove to be inaccurate because user agents can be modified (often times this is the case). The below example checks if the device is an iPad and routes the browser to another location. You will need to find out what user agents you are dealing with for the iPhone, Android, or any other device and implement this logic. Hope this helps.