第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在iOS上使用Phonegap正確檢測(cè)方向變化?

如何在iOS上使用Phonegap正確檢測(cè)方向變化?

如何在iOS上使用Phonegap正確檢測(cè)方向變化?我在下面找到了這個(gè)方向測(cè)試代碼,尋找JQTouch參考資料。這在移動(dòng)Safari上的iOS模擬器中正常工作,但在Phonegap中無(wú)法正確處理。我的項(xiàng)目遇到了與殺死此測(cè)試頁(yè)面相同的問(wèn)題。有沒(méi)有辦法在Phonegap中使用JavaScript來(lái)感知方向變化?window.onorientationchange = function() {   /*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the     left, or landscape mode with the screen turned to the right. */   var orientation = window.orientation;   switch (orientation) {     case 0:       /* If in portrait mode, sets the body's class attribute to portrait. Consequently, all style definitions matching the body[class="portrait"] declaration          in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */       document.body.setAttribute("class", "portrait");       /* Add a descriptive message on "Handling iPhone or iPod touch Orientation Events"  */       document.getElementById("currentOrientation").innerHTML = "Now in portrait orientation (Home button on the bottom).";       break;     case 90:       /* If in landscape mode with the screen turned to the left, sets the body's class attribute to landscapeLeft. In this case, all style definitions matching the          body[class="landscapeLeft"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */       document.body.setAttribute("class", "landscape");       document.getElementById("currentOrientation").innerHTML = "Now in landscape orientation and turned to the left (Home button to the right).";       break;   }
查看完整描述

3 回答

?
阿晨1998

TA貢獻(xiàn)2037條經(jīng)驗(yàn) 獲得超6個(gè)贊

這就是我做的:

function doOnOrientationChange() {
    switch(window.orientation) {  
      case -90 || 90:
        alert('landscape');
        break; 
      default:
        alert('portrait');
        break; 
    }}
  window.addEventListener('orientationchange', doOnOrientationChange);
  // Initial execution if neededdoOnOrientationChange();

根據(jù)MDNwindow.orientation,大多數(shù)瀏覽器都不支持這一功能。該事件與window.orientation相關(guān)聯(lián),因此可能不應(yīng)使用。orientationchange


查看完整回答
反對(duì) 回復(fù) 2019-08-15
?
海綿寶寶撒

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊

我使用window.onresize = function(){ checkOrientation(); } And在checkOrientation中你可以使用window.orientation或body width檢查但是想法是,“window.onresize”是最交叉的瀏覽器方法,至少對(duì)于我已經(jīng)有的大多數(shù)移動(dòng)和桌面瀏覽器有機(jī)會(huì)參加考試。


查看完整回答
反對(duì) 回復(fù) 2019-08-15
  • 3 回答
  • 0 關(guān)注
  • 531 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)