Javascript window.onload not working in iOS captive portal/network

你离开我真会死。 提交于 2020-01-04 09:19:06

问题


I've got this bit of code in the header of a jsp file. For some reason, it runs fine on desktop and mobile browsers, but on the iOS captive portal, only the first alert is triggered. Does anyone know why?

<script type="text/javascript">
  alert("first alert");
  window.onload = function() {
    alert("second alert");
  };
</script>

回答1:


I figured it out. Using this works...

<script type="text/javascript">
  alert("first alert");
  window.addEventListener('load', 
    function() { 
      alert("second alert");
    }, false);
</script>


来源:https://stackoverflow.com/questions/42568320/javascript-window-onload-not-working-in-ios-captive-portal-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!