问题
How do you programatically zoom in on a web page in a WebBrowser control in Visual C# or with JavaScript?
This is my try:
if (window.screen.width=='600')
{
document.write ('<body bgcolor="#4FB8CB" style="zoom: 55%">')
;}
else if
(window.screen.width=='800')
{
document.write ('<body bgcolor="#4FB8CB" style="zoom: 75%">')
;}
else if
(window.screen.width=='1024')
{
document.write ('<body bgcolor="#4FB8CB" style="zoom: 100%">')
;}
else if
(window.screen.width=='1152')
{
document.write ('<body bgcolor="#4FB8CB" style="zoom: 110%">')
;}
else if
(window.screen.width=='1280')
{
document.write('<body bgcolor="#4FB8CB" style="zoom: 127%">')
;}
else if
(window.screen.width=='1600')
{
document.write('<body bgcolor="#4FB8CB" style="zoom: 155%">')
;}
回答1:
The Firefox & Chrome (Webkit) equivalents to the IE-specific zoom property are, respectively, -moz-transform and -webkit-transform.
sample code :
.zoomed-element {
zoom: 1.8;
-moz-transform: scale(1.8);
-webkit-transform: scale(1.8);
}
You'd have to be a bit more careful with Javascript (test for existence first), but here's how you'd manipulate them:
el.style.zoom = 1.9;
el.style.MozTransform = 'scale(1.9)';
el.style.WebkitTransform = 'scale(1.9)';
回答2:
Refer to -ms-zoom property
Windows IE8. The -ms-zoom attribute is an extension to CSS, and can be used as a synonym for zoom in IE8 mode.
Hope it helps you.
来源:https://stackoverflow.com/questions/16836167/c-sharp-or-javascript-set-window-zoom-on-100