petranaya
petranaya

Reputation: 769

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>

Upvotes: 2

Views: 4628

Answers (1)

petranaya
petranaya

Reputation: 769

I figured it out. Using this works...

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

Upvotes: 4

Related Questions