我正在尝试从iPhone应用程序的本地资源中提供HTML Javascript和CSS内容,而且我在处理onOrientationChange事件和包括外部Javascript时遇到了问题.
我似乎能够正确地链接CSS但不是javascript.我正在尝试使用以下处理onOrientationChange的示例(如何构建iPhone网站),但我正在从我的应用程序的NSBundle mainBundle提供网页.
我尝试将一个javascript函数附加到body.onorientationchange和window.onorientationchange,但是当从本地(或远程)从UIWebView提供时,它都不起作用,但是如果我正在使用iPhone Safari,它就可以工作.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>How to build an iPhone website</title>
<meta name="author" content="will" />
<meta name="copyright" content="copyright 2008 www.engageinteractive.co.uk" />
<meta name="description" content="Welcome to engege interactive on the iPhone!" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<link rel="apple-touch-icon" href="images/template/engage.png"/>
<style type="text/css">
@import url("iphone.css");
</style>
<!--
<script type="text/javascript" src="orientation.js"></script>
-->
<script type="text/javascript">
function updateOrientation(){
try {
var contentType = "show_normal";
switch(window.orientation){
case …Run Code Online (Sandbox Code Playgroud)