用于 Opera Mini 和其他移动浏览器的 JavaScript setInterval

标签 javascript html mobile opera-mini

我在网站中使用 setInterval 函数时遇到问题。下面是我的一小部分代码。我基本上是尝试将计数增加 1 并将其打印在屏幕上。

<div id="test"></div>

<script>

var count = 0;
setInterval(function() {
    document.getElementById('test').innerHTML=count;
    count++;
}, 1000);


</script>  

编辑:我没有在代码中使用jquery,因为从上面应该很清楚。然而,我在这里面临的问题是,当我在移动设备中的 opera mini 中打开 html 时,它显示的计数是 1 到 31 到4。它不会继续。我有一个外部网址。请在移动设备中打开该网址并查看问题。 http://fundoophoto.com/raman/Test/

最佳答案

Opera Mini 实际上并不执行 javascript:

It does this by using a proxy-based architecture. Requests from the user’s handset pass through the carrier’s internet gateway on their way to Opera’s transcoding servers. These servers then forward the request to the server. Opera Mini requests pass through Opera’s servers.
The server sends the response back as normal — when this is received by the Opera transcoding servers, they parse the markup and styles, execute the JavaScript, and transcode the data into Opera Binary Markup Language (OBML). This OBML data is progressively loaded by Opera Mini on the user’s device. Think of it as an interactive snapshot of a document’s state, which is similar in form to a PDF.

您应该阅读有关此功能的页面:https://dev.opera.com/articles/opera-mini-and-javascript特别是this section关于 setIntervalsetTimeout 函数。

This means that if you use setInterval to invoke a function, it will be called a maximum of n times where n is the quotient of the timeout divided by the interval. If the interval is 1000 milliseconds, the function will be executed a maximum of five times (in newer versions of Opera Mini) before the entire script is paused (5000 ÷ 1000 = 5). If the interval is 5000 milliseconds, it will be executed no more than once before pausing.

关于用于 Opera Mini 和其他移动浏览器的 JavaScript setInterval,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27652929/

相关文章:

html - 背景颜色以适应 <p> 标签上的内容

javascript - 我可以使用对象属性值作为 css 属性值吗?

css - 在事件模式 Bootstrap 中填充父级

Javascript 倒计时在指定的日期和时间显示/隐藏

javascript - Twitter Bootstrap 3 - 测试 html 元素

css - 如何在 MaterializeCSS 中调整响应式表单的输入字段宽度?

java - 除了 Java 之外,还有其他语言可以在移动设备上无处不在吗?

mobile - 为什么 Doxygen 对手机如此不友好?

javascript - 从 MySQL 到 IndexedDB

javascript - 如何在构造函数中将属性初始化为 false?