0

如何在 Visual C# 或 JavaScript 中以编程方式放大 WebBrowser 控件中的网页?

这是我的尝试:

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%">')
;}
4

2 回答 2

1

与 IE 特定的缩放属性等效的 Firefox 和 Chrome (Webkit) 分别是 -moz-transform 和 -webkit-transform。

示例代码:

.zoomed-element {
    zoom: 1.8;
    -moz-transform: scale(1.8);
    -webkit-transform: scale(1.8);
}

您必须对 Javascript 更加小心(首先测试是否存在),但以下是您操作它们的方式:

el.style.zoom = 1.9;
el.style.MozTransform = 'scale(1.9)';
el.style.WebkitTransform = 'scale(1.9)';
于 2013-05-30T12:31:52.190 回答
0

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.

于 2013-05-30T12:30:23.177 回答