2014-10-06 40 views
2

我想動態地改變windows phonegap app中「index.html」中的元標記視口,點擊按鈕。如何在windows phonegap應用程序中加載頁面後動態更改元標記視口?

我使用

  • Windows操作系統8
  • 的PhoneGap 3.5
  • 設備諾基亞Lumia 1320與Windows 8操作系統

我想改變以下meta標籤

<meta id="viewport" name="viewport" content="width=device-width"> 

<meta id="viewport" name="viewport" content="width=720"> 

我已經嘗試過下面的URL,但沒有任何工作的Windows手機。

how to set viewport so it is 380x800 or 800x380 depending on orientation?

Setting the Viewport to Scale to Fit Both Width and Height

在這裏,我找到鏈接,它說,這是不可能的的Winodws動態改變meta標籤8 OS

http://www.quirksmode.org/blog/archives/2011/06/dynamically_cha.html

回答

0

第一寫簡單功能的JavaScript例如我已經寫一個功能視口()

<html> 
<head> 
    <script> 
     function viewport(){ 
      var msViewportStyle = document.createElement("style"); 

      msViewportStyle.appendChild(
       document.createTextNode(
        "@-ms-viewport{width:auto!important;zoom:1!important;}" 
       ) 
      ); 

      msViewportStyle.appendChild(
       document.createTextNode(
        "@-ms-viewport{height:auto!important}" 
       ) 
      ); 

      document.getElementsByTagName("head[0].appendChild(msViewportStyle); 
     } 
    </script> 
</head> 
<body> 
<button id="btnSubmit" onclick="viewport();">changeviewport</button> 
</body> 

更多.. [1]:Can I change the viewport meta tag in mobile safari on the fly?

相關問題