Click here to Skip to main content
16,005,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,


How can i change font-size of the iframe contents by clicking outside of iframe hyperlink
Posted

1 solution

Please be reminded that this is not a ready to use solution. It is merely a proof of concept and has not been tested on any other browsers than IE & FireFox. It works and might give you some ideas to explore to make it work on other browsers too. It actually does not change the font-size, but rather uses the zoom style to make the frame zoomable. Not sure if you can use this, but I found it rather neat. Enjoy!

HTML
<html>
    <style>
        #wrap { width: 600px; height: 390px; padding: 0; overflow: hidden; }
        #frame { width: 800px; height: 520px; border: 1px solid black; }
        #frame { zoom: 0.75; -moz-transform: scale(0.75); -moz-transform-origin: 0 0; }
    </style>
    <body>
        <p>Some text before the frame</p>
        <div id="wrap">
            <iframe id="frame" src="http://www.apache.org"></iframe>
        </div>
        <p>Some text after the frame</p>
        <form>
            <input type="button" value="Zoom out" name="btn_zoomout" onclick="zoomout();"/>
            <input type="button" value="Zoom in"  name="btn_zoomin"  onclick="zoomin();"/>
         </form>
        <script type="text/javascript">
            var zoom = 0.75;
            function zoomout()
            {
               zoom = zoom - 0.1;
               var element = document.getElementById("frame");
               // This line does the trick for FireFox
               element.style.MozTransform = "scale(" + zoom + ")";
               // This line does the trick for IE
               element.style.zoom = "" + zoom;
            }
            function zoomin()
            {
               zoom = zoom + 0.1;
               var element = document.getElementById("frame");
               // This line does the trick for FireFox
               element.style.MozTransform = "scale(" + zoom + ")";
               // This line does the trick for IE
               element.style.zoom = "" + zoom;
            }
        </script>
    </body>
</html>


Regards,

Manfred
 
Share this answer
 
v4
Comments
Manfred Rudolf Bihy 13-Jun-12 12:10pm    
Added two lines to make it work in FireFox too! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900