1 Reply Latest reply: Nov 29, 2013 6:44 AM by Gaurav.S RSS

    Inserting a button to zoom out a page.

    timpennells Community Member

      Hi,

       

      I have a piece of code to zoom the page in, so i changed a few bits to zoom the page out and it only works in firefox, here it is:

       

      <a href="#" ONCLICK="if(window.parent.document.body.style.zoom!=0)

       

      window.parent.document.body.style.MozTransform = 'scale(1.0)';

       

      else window.parent.document.body.style.zoom=1.0;" 

      >

          <img src="http://www.wearemogul.com/more.png" alt="zoom in"/>

      </a>

       

      Obviously the if statement is returning true as it does the .MozTransform and misses the else bit, in the zoom in code all that is different is 'scale(1.5)' and zoom=1.5

       

      any ideas?

        • 1. Re: Inserting a button to zoom out a page.
          Gaurav.S Employee Hosts

          Hi,

           

          The code that you have mentioned looks like for Mozila Firefox only. Try the Code below, this will add the Zoom Text effect

           

          This goes in Page Head section

           

          <script type=text/javascript>

          var fontSize = 1;

          function zoomIn() {

              fontSize += 0.1;

              document.body.style.fontSize = fontSize + "em";

          }

          function zoomOut() {

              fontSize -= 0.1;

              document.body.style.fontSize = fontSize + "em";

          }

          </script>

           

           

          Now on your Page, add this using insert html

          <input type="button" value="+" onClick="zoomIn()"/>

          <input type="button" value="-" onClick="zoomOut()"/>

           

          Hope this helps