2016-07-07 48 views
1

我發現iOS設備上顯示Google Apps腳本HtmlService的問題。如果html的內容高於視口的高度,則iOS設備不啓用滾動。有什麼辦法可以強制這個嗎?以下代碼將重現iOS設備上的問題。Google Apps腳本中iOS視口的問題

function doGet() { 
    return HtmlService.createTemplateFromFile('html') 
     .evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME).addMetaTag("viewport", "width=device-width,initial-scale=1").setTitle("Whatever") 

} 


"html" file 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 

<title>Prep Notes Viewer-Editor</title> 



<link type="text/css" rel="stylesheet" > 

</head> 


<body> 

<div id="output"> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Line <br> 
Last Line 
</div> 

</body> 
</html> 
+0

你應該公佈你的腳本,並給每個人的匿名訪問,並張貼喜歡這裏,使人們可以測試它。 –

+0

這是一個鏈接。 https://script.google.com/d/1j2I3Gr6qXbN5PQjq4tBIb2dex4mVkNRYBLf5mLiCWCVlFYi2-MC7QY9Y/edit?usp=sharing – user2970721

回答

1

我想通了一個辦法。

後身體右側添加一個div元素(姑且稱之爲#backgroundBox),圍繞着整個身體的HTML,那div元素的CSS設置爲:

#backgroundBox{ 
    height:100%; 
    width:100%; 
    position:absolute; 
    top:0%; 
    left:0%; 
    margin:0px; 
    padding:0px; 
    overflow:scroll; 
} 

又一次的HTML會是什麼樣子這樣的:

"html" file 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 

<title>Prep Notes Viewer-Editor</title> 



<link type="text/css" rel="stylesheet" > 

</head> 


<body> 
<div id="#backgroundBox"> 
    <div id="output"> 
    Line <br> 
    Line <br> 
    MORE LINES 
    </div> 
</div> 
</body> 

+0

注意:使用此修補程序的iOS設備的慣性滾動。如果添加-webkit-overflow-scrolling:touch;問題返回到你無法滾動的地方。 – user2970721