0
我創造與PhoneGap的(科爾多瓦)框架的IOS/Android應用程序。我的UI代碼在水平方向上有點缺乏。所以,我只想改變水平方向而不是垂直方向的外觀和感覺。有,我可以在index.html的適用於實現這一目標,preferrably在javascript/jquery
的條件。提前致謝。條件水平方向+ IOS/Android應用開發
我創造與PhoneGap的(科爾多瓦)框架的IOS/Android應用程序。我的UI代碼在水平方向上有點缺乏。所以,我只想改變水平方向而不是垂直方向的外觀和感覺。有,我可以在index.html的適用於實現這一目標,preferrably在javascript/jquery
的條件。提前致謝。條件水平方向+ IOS/Android應用開發
您可以創建事件onOrientationChange()中,你或許可以改變它適用於某一特定方向的CSS文件中的事件偵聽器。
// create the link tag for the css file in your head section
<HEAD>
<LINK ID="OrientationSpecificCSSTag" REL="stylesheet" TYPE="text/css" HREF=""> // keep the href empty, will set later
.....
</HEAD>
現在附加事件偵聽器在JavaScript文件或腳本標籤
// attach the onOrientationChange event listener in your script tag
window.addEventListener('onorientationchange', OnOrientationChange, false);
依據方位
function OnOrientationChange()
{
// case: if portrait
if(window.orientation == 0 || window.orientation == 270)
{
document.getElementById('OrientationSpecificCSSTag').HREF = 'landscape.css';
}
else
{
document.getElementById('OrientationSpecificCSSTag').HREF = 'portrait.css';
}
}
落實OnOrientationChange功能,實際上改變了css文件