如何在uiwebview中处理javascript onorientationchange事件
任何人都可以帮助我在iphone中通过uiwebview访问时如何处理javascript中的方向更改事件?
我想捕获
onorientationchange
javascript的事件。我试过以下代码。
<style type="text/css" media="only screen and (max-device-width: 480px)">
.portrait
{
width: 300px;
padding: 0 15px 0 5px;
}
.landscape
{
width: 460px;
padding: 0 15px 0 5px;
}
</style>
<script type="text/javascript">
window.onload = orientationchange;
window.onorientationchange = orientationchange;
function orientationchange() {
if (window.orientation == 90
|| window.orientation == -90) {
document.getElementById('contents').className = 'landscape';
}
else {
document.getElementById('contents').className = 'portrait';
}
}
</script>
// and I have a div inside html
<div id="contents">
my contents and description... e.t.c, and e.t.c...
</div>
它在safari中工作正常但是当我使用uiwebview访问页面时,没有捕获方向更改事件,并且无法实现我想要的功能。
没有找到相关结果
已邀请:
3 个回复
磐乓铝举
祁澈盘哼颗
撵穆
:
现在你可以用正确的方向调用你的webview :)