Skip to content

Instantly share code, notes, and snippets.

@pec1985
Created April 21, 2011 01:23
Show Gist options
  • Save pec1985/933459 to your computer and use it in GitHub Desktop.
Save pec1985/933459 to your computer and use it in GitHub Desktop.
Increase zoom level in WebView
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();
@dickfala
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment