Tuesday, February 28, 2012

Zoom In Zoom Out Contents of Page using JQuery CSS3

// Include JQuery File
<script type="text/javascript">
        $(document).ready(function () {
            var currZoom = $("#divpnlChart").css("zoom");
            if (currZoom == 'normal') currZoom = 1; // For IE

            $(".zoomIn").click(function () {
                currZoom *= 1.2;
                $("#divpnlChart").css("zoom", currZoom);
                $("#divpnlChart").css("-moz-transform", "Scale(" + currZoom + ")");
                $("#divpnlChart").css("-moz-transform-origin", "0 0");

            });
            $(".zoomOff").click(function () {
            $("#divpnlChart").css("zoom", 1);
$("#divpnlChart").css("-moz-transform", "Scale(" + currZoom + ")");
            $("#divpnlChart").css("-moz-transform-origin", "0 0");

            });
            $(".zoomOut").click(function () {
                currZoom *= .8;
              $("#divpnlChart").css("zoom", currZoom);
              $("#divpnlChart").css("-moz-transform", "Scale(" + currZoom + ")");
              $("#divpnlChart").css("-moz-transform-origin", "0 0");

            });
        });
</script>

//  HTML Code

<span class="zoomIn" style="font-size:120%">A</span>
<span class="zoomOff">A</span>
<span class="zoomOut" style="font-size:80%">A</span>

<div id="divpnlChart" runat="server" style="float: left; width: 85%;">
    //  your content
</div>

5 comments:

  1. Working good in Chrome but not in Firefox

    ReplyDelete
    Replies
    1. We have given seperately "-moz" style css to run in firefox only. But not sure why it not working for you..

      Delete
  2. Thanks Balajiprasad.

    firefox version that worked for me
    $("#divpnlChart").css("-moz-transform", "scale(" + currZoom + " , " + currZoom + ")");

    ReplyDelete