0

jQueryまたはそのhtmlコンテンツをズームインおよびズームアウトするために必要なその他のツールを使用して、テキストやテーブルなどのhtmlコンテンツを含むdivがあります。

以下のコードを試しましたが、Firefox では動作しません。

HTML

<input type="button" id="zoomin" value="+" onclick="return ZoomIn();">
<input type="button" id="zoomout" value="-"  onclick="return ZoomOut();"> 
<div class="imgBox" id="imgBox" style="zoom: 100%;">
//My content
</div>

JS

function ZoomIn() {
    var ZoomInValue = parseInt(document.getElementById("imgBox").style.zoom) + 10 + '%'
document.getElementById("imgBox").style.zoom = ZoomInValue;
return false;
}

function ZoomOut() {
var ZoomOutValue = parseInt(document.getElementById("imgBox").style.zoom) - 10 + '%'
document.getElementById("imgBox").style.zoom = ZoomOutValue;
return false;
}

上記のコードは Chrome と IE では機能しますが、Firefox では機能しません。これに対する修正は何ですか?ありがとう。

4

1 に答える 1

0

zoomFirefox はこのプロパティをサポートしていません: http://www.browsersupport.net/CSS/zoom

以下は、CSS を使用して FF で同様の効果を得るために必要なものの例です。

-moz-transform: scale(4);

次のようなものを使用して、これを JS に適用できます。

document.getElementById("imgBox").style.MozTransform = 'scale(4)';
于 2013-11-06T14:01:00.383 に答える