问题
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