为什么不是Word中的Visual composer页面构建器的Raw js元素中的window.location.href

问题描述 投票:0回答:1

在我的Wordpress网站上,我有Visual composer页面构建器插件。在那,我正在创建一个按钮,如果从苹果手机点击,将重定向到Apple商店,如果从Android点击将重定向到谷歌游戏商店。我通过一个脚本来做这个,我把它放在视觉作曲家的Raw js元素中。下面是脚本:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script>
jQuery(function ($) {
    $( document ).ready(function() {
        $(".custom_button").on("click", function(){

        if(navigator.userAgent.toLowerCase().indexOf("android") > -1){ alert('in android');
            window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
        }
        if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){ alert('in iphone');
           window.location.href = 'http://itunes.apple.com/';
               alert('after iphone');
         }
        });
     });
  });
</script>

window.location.href不起作用。它没有重定向。它运行一个脚本,并在“iphone”和“在iphone之后”发出警报,但它不会重定向到任何商店。

javascript jquery wordpress visual-composer
1个回答
0
投票

我认为这可能与Why isnt window.location.href= not forwarding to page using Safari?重复(或非常相似)

有一些建议的Safari解决方法,可能是你在iPhone上使用的。

© www.soinside.com 2019 - 2024. All rights reserved.