Search code examples
javascriptiosonloadcaptivenetworkcaptiveportal

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


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>


Solution

  • I figured it out. Using this works...

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