Created
April 21, 2011 01:23
-
-
Save pec1985/933459 to your computer and use it in GitHub Desktop.
Increase zoom level in WebView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Titanium.UI.createWindow({ | |
backgroundColor:'#fff' | |
}); | |
var webView = Ti.UI.createWebView({ url:'http://www.appcelerator.com', scalesPageToFit:true,setZoomScale:2, top:0, left:0}); | |
win.add(webView); | |
var firstTime = true; | |
var htmlHack = ''; | |
htmlHack += 'var element = document.createElement("meta");'; | |
htmlHack += 'element.name = "viewport";'; | |
htmlHack += 'element.content = "maximum-scale=100";'; | |
htmlHack += 'var head = document.getElementsByTagName("head")[0];'; | |
htmlHack += 'head.appendChild(element);'; | |
webView.addEventListener('load', function(e){ | |
webView.evalJS(htmlHack); | |
}); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sorry. I have a question. This method can zoom scale initially, but user can't change zoom in zoom out after.
I try to add htmlHack += 'element.content =user-scalable=yes"; .
It is still can't change zoom by user .
Have any method can change zoom scale and set web view scale initially?
thank you very much.