hi using code given below.i want increase or decrease text font size on web browser using a+ , a- buttons.i getting html file xml feed.so 1 resolve in solution.
<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 gold , shilpa seems have pulled off in style on nach baliye 5. other stars spotted ajay devgn , akshay kumar kajal agarwal promoting film special 26. though kajal looked pretty in anarkali, not quite compete 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); } }
i using code nothing change font size.so me 1 how solve in solution.
you have use webbrowser.invokescript:
// initial text size int textsize = 100; // percentage private void a+_click(object sender, eventargs e) { textsize *= 2; // can modify not increase 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 not decrease 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); }
check out this post on msdn.
Comments
Post a Comment