<body onload="javascript function">
在桌面浏览器上运行良好,但无法在iPhone上运行。我的iPhone似乎可以读取外部CSS文件和JS文件,因为当我从页面点击按钮时,它会触发JS函数。但奇怪的是,只有onload
事件无效。我现在很无能为力。任何人都可以告诉我为什么我不能在iPhone上发起onload事件?以下是我的代码。
<!DOCTYPE HTML>
<html>
<head>
<title>HTML5 연습</title>
<meta name="viewport" content="width=480, user-scalable=1"/>
<link rel="stylesheet" href="../styles/test1.css" />
<script type="text/javascript" src="../scripts/fbsdk.js"></script>
<script type="text/javascript" src="../scripts/initcss.js"></script>
<script>
//document.addEventListener('DOMContentLoaded', checkLoginCase, false);
</script>
</head>
<body onload="checkLoginCase()">
<div id="wrap">
<header id="top">
<img src="../fbimg/logo.png" alt="상단이미지" title="상단이미지">
</header>
</div>
<button onclick="checkLoginCase()"> check fxn1</button>
<button onclick="checkAlert()"> check fxn2</button>
</body>
</html>
答案 0 :(得分:2)
它应该正常工作,但尽量避免使用内联JavaScripts。
试试这个:
window.onload = (function(){
checkLoginCase();
});
//-or-
window.onload = checkLoginCase;