Change font size : Font « HTML « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Dojo toolkit
7. Event
8. Event onMethod
9. Ext JS
10. Form Control
11. GUI Components
12. HTML
13. Javascript Collections
14. Javascript Objects
15. Javascript Properties
16. jQuery
17. Language Basics
18. Mochkit
19. Mootools
20. Node Operation
21. Object Oriented
22. Page Components
23. Rico
24. Scriptaculous
25. Security
26. SmartClient
27. Style Layout
28. Table
29. Utilities
30. Window Browser
31. YUI Library
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript DHTML » HTML » Font 
Change font size

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- 
     Example File From "JavaScript and DHTML Cookbook"
     Published by O'Reilly & Associates
     Copyright 2003 Danny Goodman
-->
<html>
<head>
<title>Change font size </title>
<style rel="stylesheet" id="mainStyle" type="text/css">
html {background-color:#cccccc}
body {background-color:#eeeeee; font-family:Tahoma,Arial,Helvetica,sans-serif; font-size:12px;
    margin-left:15%; margin-right:15%; border:3px groove darkred; padding:15px}
h1 {text-align:right; font-size:1.5em; font-weight:bold}
h2 {text-align:left; font-size:1.1em; font-weight:bold; text-decoration:underline}
.buttons {margin-top:10px}

</style>
<style id="normalStyle" type="text/css">
body {font-family:Verdana, Helvetica, sans-serif;
      font-size:small}
#textSizer {text-align:right; display:none}
.textSize {border:1px solid black}
</style>
<style id="sizer" type="text/css" disabled="disabled">
    #textSizer {display:block}
</style>
<style id="smallStyle" type="text/css" disabled="disabled">
    body {font-size:xx-small}
</style>
<style id="largeStyle" type="text/css" disabled="disabled">
    body {font-size:large}
</style>
<script type="text/javascript" src="../js/cookies.js"></script>
<script type="text/javascript">
// enable/disable 
function setSizeStyle() {
    if (document.getElementById) {
        document.getElementById("sizer").disabled = false;            
        var styleCookie = getCookie("fontSize");
        var styleIDs = ["smallStyle""largeStyle"];
        for (var i = 0; i < styleIDs.length; i++) {
            if (styleCookie == styleIDs[i]) {
                document.getElementById(styleIDs[i]).disabled = false;            
            else {
                document.getElementById(styleIDs[i]).disabled = true;    
            }
        }
    }
}
// set active style now, before content renders
setSizeStyle();

// invoked by clicking on sizer icons
function changeSizeStyle(styleID) {
    setCookie("fontSize", styleID, getExpDate(18000));
    setSizeStyle();
}
</script>
</head>
<body style="background-color:#ffffff">
<h1 style="font-size:26px; font-weight:bold">User-selectable Font Sizes</h1>
<div id="textSizer">
<img src="fontSizer.jpg" height="18" width="72" alt="Font Sizer"><a 
href="" onclick="changeSizeStyle('smallStyle'); return false"><img 
class="textSize" src="fontSmall.jpg" height="18" width="18" 
alt="Smallest" /></a><a href="" onclick="changeSizeStyle(''); return false"><img 
class="textSize" src="fontMedium.jpg"  height="18" width="18" alt="Default" /></a><a 
href="" onclick="changeSizeStyle('largeStyle'); return false"><img 
class="textSize" src="fontLarge.jpg" height="18" width="18" alt="Biggest" /></a>
</div>
<hr /> 

<p>Lorem ipsum dolor sit amet, consectetaur adipisicing elit, sed do eiusmod tempor 
incididunt ut labore et dolore magna aliqua. Ut enim adminim veniam, quis nostrud 
exercitation ullamco laboris nisi ut aliquip ex ea commodo 
consequat.
</p>


</body>
</html>


           
       
Related examples in the same category
1. Font array and date
2. Controlling FONT Object Properties
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.