Javascript window.onload 在 iOS 强制门户/网络中不起作用
<p><p>我在一个 jsp 文件的头部有这段代码。出于某种原因,它在桌面和移动浏览器上运行良好,但在 iOS 强制门户上,只触发了第一个警报。有谁知道为什么?</p>
<p></p><div class="snippet"data-lang="js"data-hide="false"data-console="true"data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code><script type="text/javascript">
alert("first alert");
window.onload = function() {
alert("second alert");
};
</script></code></pre>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我想通了。使用这个作品...... </p>
<p></p><div class="snippet"data-lang="js"data-hide="false"data-console="true"data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code><script type="text/javascript">
alert("first alert");
window.addEventListener('load',
function() {
alert("second alert");
}, false);
</script></code></pre>
<p style="font-size: 20px;">关于Javascript window.onload 在 iOS 强制门户/网络中不起作用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/42568320/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/42568320/
</a>
</p>
页:
[1]