如何在windows phone中使用按钮增加或减少网页浏览器字体大小
How to increase or decrease web browser font size using button in windows phone?
我正在使用下面给出的代码。我想增加或减少使用A+和A-按钮的网页浏览器上的文本字体大小。我从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-_Click(object sender, RoutedEventArgs e)
{
if (i > 2)
{
webBrowser.FontSize -= 2;
i++;
j = i;
}
}
private void A+_Click(object sender, RoutedEventArgs e)
{
if (i < 3)
{
webBrowser.FontSize += 2;
i++;
j = i;
}
}
<Fullcontent>
<html>
<body>
<p>When worn right, there’s nothing quite like gold and Shilpa seems to have pulled off the look in style on Nach Baliye 5. Other stars spotted were Ajay Devgn and Akshay Kumar with Kajal Agarwal promoting their film Special 26. Though Kajal looked pretty in an Anarkali, she could not quite compete with Shilpa.</p>
</body>
</html>
</Fullcontent>
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string selectedIndex = "";
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
webBrowser.NavigateToString(App.CurrentArticle.FullContent);
}
}
我正在使用这个代码,但没有改变字体大小。所以谁来帮我解决这个问题
你必须使用WebBrowser。InvokeScript:
// 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);
}
>
相关文章:
- 如何正确地以无限滚动浏览网页
- 我可以'我无法让我的网页浏览JScript中选择列表中的trhorugh URL
- 如何在不知道域名的情况下跟踪网站的网页浏览量
- 欧芹js在触发虚拟网页浏览之前检查错误
- 谷歌分析当前网页浏览网址被事件覆盖
- 禁止全能 S.t() 调用在使用 iframe 的网站中生成“第二次”网页浏览
- 如何禁用谷歌分析网页浏览量跟踪,但保留事件跟踪
- 在不使用 Flash 的情况下浏览网页中的 PDF
- 如何查找有多少用户同时浏览您的网页
- Google Analytics(分析)跟踪网页浏览会自动向网址添加斜杠
- 浏览网页时如何更改内容
- 如何从网页浏览文件夹并在页面上显示其内容
- 在python下使用javascript实现网页浏览的自动化
- myfonts如何跟踪网页浏览量为他们的网页字体
- 哪一种浏览速度更快?从不同的网站下载不同的图片/一个网站为一个网页's图片[HTML/PHP]
- Angular 2——浏览网页时不需要重新加载那些页面中常见的组件
- 知道用户什么时候浏览网页
- 连接路径名与虚拟URL跟踪网页浏览量
- 网页浏览动态文件夹结构
- 点击网页上的一个按钮,可以生成一个动态链接吗?我们可以浏览网页到动态生成的链接