通过JavaScript代码重定向后,Shopify页面不断刷新
您能告诉我问题是什么,或者至少我如何通过开发工具检测到它? 谢谢
I am trying to create a website https://fone-kase-plus.myshopify.com/ that will detect what device model it's being accessed from (for example GALAXY A40) so it will immediately redirect the user to a corresponding page.
It seems to be working, but it will reload the page multiple times after redirecting. If I try to redirect it to non-shopify page (eg stackoverflow.com) this problem doesn't occur.
function deviceAPIcallback(result){
if(result.deviceName == "desktop"){
window.location.href = "https://fone-kase-plus.myshopify.com/pages/galaxy-a40";
}
else{
alert(result.deviceName);
}
}
Can you please tell me what the problem can be or at least how I can detect it by dev tools?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我从MacOS笔记本电脑和iPhone访问网站时,我只会获得您功能的警报方面。
result.devicename
返回什么?如果'语句,您可能需要将第三个'='添加到您的第一个''中。When I go to the site from both my macOS laptop and my iPhone I only get the alert aspect of your function. What does
result.deviceName
return? You might need to add a third '=' to your first 'if' statement.