【问题标题】:iFrame redirecting & reload homepage issue on mobile phoneiFrame 在手机上重定向和重新加载主页问题
【发布时间】:2017-10-28 03:06:04
【问题描述】:

我下面的两个代码运行良好。第一个代码在电脑上运行良好,第二个代码在手机上运行。但我想在移动设备上使用第一个代码和第二个代码代理在 30 秒后自动重新加载。
如何在第一个代码上添加第二个移动代理代码?

第一个代码:

<script>
window.setInterval("reloadIFrame();", 30000);
function reloadIFrame() {
document.getElementById("test").src="http://example.com";
}
</script>

第二个代码:

<script>
var isMobile = function() {
return /(iphone|ipod|ipad|android|blackberry|windows 
ce|palm|symbian)/i.test(navigator.userAgent);
};
if(isMobile()) {
window.location.href = "https://example.com";
}
</script>

对不起,英语不好。
请帮我解决它。谢谢

【问题讨论】:

    标签: javascript jquery iframe jquery-mobile mobile


    【解决方案1】:

    据我所知,您也在尝试在移动页面中使用相同的延迟功能。在这里你可以试试这个,问有没有问题:

    /* Define the functions */
    
    var reloadIFrame = function() {
        document.getElementById("test").src="http://example.com";
    };
    
    var isMobile = function() {
        return /(iphone|ipod|ipad|android|blackberry|windows ce|palm|symbian)/i.test(navigator.userAgent);
    };
    
    /* Begin */
    
    if (isMobile()) {
        window.setInterval("reloadIFrame();", 30000);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-04
      • 2015-10-08
      • 2020-02-15
      相关资源
      最近更新 更多