Javascript 如何在windows phone中使用按钮增加或减少web浏览器字体大小?

Javascript 如何在windows phone中使用按钮增加或减少web浏览器字体大小?,javascript,windows-phone-7,c#-4.0,xml-parsing,Javascript,Windows Phone 7,C# 4.0,Xml Parsing,您好,我正在使用下面给出的代码。我想使用A+和A-按钮增加或减少web浏览器上的文本字体大小。我正在从xml提要获取html文件。因此,在此解决方案中,任何人都可以帮助解决此问题 <phone:WebBrowser x:Name="webBrowser" Height="592" IsScriptEnabled="True" /> <Button BorderThickness="0" Margin="0,0,18,0" Height="88" HorizontalAli

您好,我正在使用下面给出的代码。我想使用A+和A-按钮增加或减少web浏览器上的文本字体大小。我正在从xml提要获取html文件。因此,在此解决方案中,任何人都可以帮助解决此问题

<phone:WebBrowser x:Name="webBrowser" Height="592"  IsScriptEnabled="True" />
<Button BorderThickness="0"   Margin="0,0,18,0" Height="88" HorizontalAlignment="Right" Width="96" x:Uid="#aPlus" Click="A-_Click" >

private void A-\u单击(对象发送方、路由目标方)
{
如果(i>2)
{
webBrowser.FontSize-=2;
i++;
j=i;
}
}
私有无效A+\u单击(对象发送者,路由目标e)
{
如果(i<3)
{
webBrowser.FontSize+=2;
i++;
j=i;
}
}
正确佩戴时,会出现以下问题:;它与黄金完全不同,Shilpa似乎已经在Nach Baliye 5上完成了时尚外观。其他被发现的明星还有Ajay Devgn和Akshay Kumar以及Kajal Agarwal宣传他们的电影特辑26。虽然卡哈尔穿着阿纳卡利服装看起来很漂亮,但她无法与希尔帕竞争

受保护的覆盖无效OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { 字符串selectedIndex=“”; if(NavigationContext.QueryString.TryGetValue(“selectedItem”,out selectedIndex)) { webBrowser.NavigateToString(App.CurrentArticle.FullContent); } }

我正在使用此代码,但无法更改字体大小。因此,请帮助我解决此解决方案中的任何问题。

您必须使用WebBrowser.InvokeScript:

<phone:WebBrowser x:Name="webBrowser" Height="592"  IsScriptEnabled="True" />
<Button BorderThickness="0"   Margin="0,0,18,0" Height="88" HorizontalAlignment="Right" Width="96" x:Uid="#aPlus" Click="A-_Click" >
// Initial text size
int textSize = 100; // Percentage

private void A+_Click(object sender, EventArgs e)
{
    textSize *= 2; // Can modify to not increase so much each time
    string szfn = "{styleText = \"body { -ms-text-size-adjust:" + textSize + "% }\";styleTextNode = document.createTextNode(styleText);styleNode = document.createElement(\"style\");styleNode.appendChild(styleTextNode);document.getElementsByTagName(\"head\")[0].appendChild(styleNode);};";
    webBrowser.InvokeScript("eval", szfn);
}

private void A-_Click(object sender, EventArgs e)
{
    textSize /= 2; // Can modify to not decrease so much each time
    string szfn = "{styleText = \"body { -ms-text-size-adjust:" + textSize + "% }\";styleTextNode = document.createTextNode(styleText);styleNode = document.createElement(\"style\");styleNode.appendChild(styleTextNode);document.getElementsByTagName(\"head\")[0].appendChild(styleNode);};";
    webBrowser.InvokeScript("eval", szfn);
}
退房