Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检测Safari并重定向_Javascript_Html_Redirect - Fatal编程技术网

Javascript 检测Safari并重定向

Javascript 检测Safari并重定向,javascript,html,redirect,Javascript,Html,Redirect,我目前使用此脚本在使用safari时检测并重定向页面 if(/safari/.test(navigator.userAgent.toLowerCase())) { window.location.href = "elsewhere.html" } 然而,它在safari和chrome中重定向 如何使其仅在safari中重定向?只需将此脚本放入标题中即可。它应该只检测和重定向safari。只需将window.location.href=somewhere.html更改为要重定向safar

我目前使用此脚本在使用safari时检测并重定向页面

if(/safari/.test(navigator.userAgent.toLowerCase())) {
    window.location.href = "elsewhere.html"
}
然而,它在safari和chrome中重定向


如何使其仅在safari中重定向?

只需将此脚本放入标题中即可。它应该只检测和重定向safari。只需将window.location.href=somewhere.html更改为要重定向safari用户的url即可

<script>
var ua = navigator.userAgent.toLowerCase(); 
 if (ua.indexOf('safari')!=-1){ 
   if(ua.indexOf('chrome')  > -1){

   }else{
    window.location.href = "somewhere.html" // saf
   }
  }

</script>

只要把这个脚本放到你的头上。它应该只检测和重定向safari。只需将window.location.href=somewhere.html更改为要重定向safari用户的url即可

<script>
var ua = navigator.userAgent.toLowerCase(); 
 if (ua.indexOf('safari')!=-1){ 
   if(ua.indexOf('chrome')  > -1){

   }else{
    window.location.href = "somewhere.html" // saf
   }
  }

</script>
请尝试以下简单代码:

请尝试以下简单代码:

试试这个:

if(typeof navigator.vendor!='undefined' && navigator.vendor.toLowerCase().indexOf('apple')!=-1){
 // redirection
}
试试这个:

if(typeof navigator.vendor!='undefined' && navigator.vendor.toLowerCase().indexOf('apple')!=-1){
 // redirection
}
我的智能代码是:

var uagent = navigator.userAgent.toLowerCase();
if(/safari/.test(uagent) && !/chrome/.test(uagent))
{
    window.location.href = "elsewhere.html"
}
我的智能代码是:

var uagent = navigator.userAgent.toLowerCase();
if(/safari/.test(uagent) && !/chrome/.test(uagent))
{
    window.location.href = "elsewhere.html"
}

你能发布到该网站的链接吗?检查:“我当前使用此脚本在使用safari时检测并重定向页面”-为什么?嗨,我当前无法发布链接,因为这是私有的。但我面临的问题是,它在safari和chrome上都会重定向。我如何仅在safari中检测和重定向可能你应该修复该内容,而不是尝试检测safari?你可以发布一个链接到该网站吗?检查:“我当前使用此脚本在使用safari时检测和重定向页面”-为什么?嗨,我目前无法发布链接,因为这是私有的。但我面临的问题是,它在safari和chrome上都会重定向。如何仅在safari中检测和重定向可能您应该修复该内容,而不是尝试检测safari?