Click here to Skip to main content
14,427,173 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello All,
i have a master page and master page body id= "sitebody1" and on clicking a button i am increasing the font size by javascript function.
The font size of master page contents are increasing but content page font size is not increased.
following is sample code
Jacascript
function set_font_size(fontType) {
        if (fontType == "increase") {
            if (fontSize < 100) {
                fontSize = parseInt(fontSize) + 15;
            }
        } else {
            fontSize = 75;
        }
      document.getElementById("sitebody1").style.fontSize = fontSize + "%";

Design
<body id="sitebody1">
 onclick="set_font_size('increase')
of a button
Posted
Updated 7-Oct-15 1:36am
v2
Comments
Naveen.Sanagasetti 7-Oct-15 6:36am
   
Make sure while posting a question please follow the rules and regulations.
[no name] 7-Oct-15 7:07am
   
As per code, it should work in both the pages. Is any other CSS in child page which overriding the font-size property. Please cross check.
Member 8232678 8-Oct-15 0:24am
   
Thanks sir,
As you told child page have a css style and after removing it, its works fine.
[no name] 8-Oct-15 0:42am
   
:)
Member 8232678 8-Oct-15 5:08am
   
can we override the content page css from master page?
[no name] 8-Oct-15 5:29am
   
yes, it is possible. Use !important in css class and add that dynamically through javascript.

.p {
font-style: normal;
color: red !important;
}
Member 8232678 16-Oct-15 0:29am
   
THANKS

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

There is no sign of fontSize!
Also your indentation of code suggest that you think that the else part belongs to the if(fontType...) where it belongs to the if(fontSize...) part...

Check here a jquery aided solution (of some kind): http://jsfiddle.net/1qhk4w38/[^]
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100