Pradeep Kesharwani
Pradeep Kesharwani

Reputation: 1478

I want to disable Zoom In and Out feature of web browser control in wp8

 private void webBrowserDescription_LoadCompleted_1(object sender, NavigationEventArgs e)
 {
     this.webBrowserDescription.InvokeScript("eval", new[] { "document.getElementsByTagName('head')[0].appendChild('<meta name=\"viewport\" content=\"width=device-width,user-scalable=no \">')"});
 }

But got An unknown error has occurred. Error: 80020101.

How can I resolve this to disable Zoom in - Zoom Out feature

Upvotes: 0

Views: 1710

Answers (3)

Pradeep Kesharwani
Pradeep Kesharwani

Reputation: 1478

I got Solution by chainging my way,here i used navigateToString instead of InvokeScript method:

BrowserControl.LoadCompleted += Browser_LoadCompleted;
private void Browser_LoadCompleted(object sender, NavigationEventArgs e)
{
  string myhtml = BrowserControl.SaveToString();
  string mataTag = "<meta name=\"viewport\" content=\"width=320,user-scalable=yes\" />";
  myhtml = html.Insert(html.IndexOf("<head>", 0) + 6, mataTag);
  BrowserControl.NavigateToString(html);
  BrowserControl.LoadCompleted -=  Browser_LoadCompleted;
}

Upvotes: 0

Alen Lee
Alen Lee

Reputation: 2509

Try this

<meta name="viewport" content="user-scalable=no" />

Upvotes: 1

user1470953
user1470953

Reputation:

Are you able to use a meta tag in the page header? I don't know if wp8 recognizes those or not. e.g.

<meta name="viewport" content="user-scalable=no, initial-scale=1, 
maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, 
target-densitydpi=device-dpi" />

Upvotes: 0

Related Questions