<body onload="javascript function">
is working well on desktop browser, but is not working on iPhone. My iPhone seems like it can read external CSS files and JS files, since when I click button from page, it fires JS functions. But oddly, only onload
event is not working. I am so clueless now. Can anybody tell me why can't I fire onload event on iPhone? Below is my code.
<!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>
<body onload="javascript function">
is working well on desktop browser, but is not working on iPhone. My iPhone seems like it can read external CSS files and JS files, since when I click button from page, it fires JS functions. But oddly, only onload
event is not working. I am so clueless now. Can anybody tell me why can't I fire onload event on iPhone? Below is my code.
<!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>
Share
Improve this question
edited Jun 7, 2012 at 6:05
Derek 朕會功夫
94.5k45 gold badges198 silver badges253 bronze badges
asked Jun 7, 2012 at 6:02
Seho LeeSeho Lee
4,1089 gold badges34 silver badges42 bronze badges
3
- let me check... my iOS version is 5.0.1 – Seho Lee Commented Jun 7, 2012 at 6:17
- does your code also work using Safari on your desktop or if you access this page with the ipad's Safari (not in an UIWebView, with the ipad stand-alone browser)? – BBog Commented Jun 7, 2012 at 6:53
- Turn on mobile safari developer mode (In Settings -> mobile safari) to see if any error found in the script. Script error may break the onload event. – vincicat Commented Jun 7, 2012 at 6:55
1 Answer
Reset to default 2It should be working, but try to avoid inline JavaScripts.
Try this:
window.onload = (function(){
checkLoginCase();
});
//-or-
window.onload = checkLoginCase;
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745493872a4630108.html
评论列表(0条)