Saturday, December 12, 2020

New Promise Let Site Visitors To Alter Font Sizes On Your Blog

array of font sizes or a unproblematic a hack that allows visitors to alter fonts families on a webpage.

Here, nosotros utilisation the White Hat hack since it's unproblematic to implement in addition to does the chore alongside few lines of code.

Step 1: Add the next Javascript inwards the insde the <HEAD> tag of your HTML.
<script language="JavaScript" type="text/javascript">
function changeFontSize(inc)
{
var p = document.getElementsByTagName('p');
for(n=0; n<p.length; n++) {
if(p[n].style.fontSize) {
var size = parseInt(p[n].style.fontSize.replace("px", ""));
} else {
var size = 12;
}
p[n].style.fontSize = size+inc + 'px';
}
}
</script>
Step 2: Insert the next HTML anywhere inwards your weblog - yous tin customize the text or supervene upon it alongside visual graphics (like the alphabet H5N1 - i modest in addition to the other i slightly large)
<a href="javascript:changeFontSize(1)">Increase Font Size</a> 
<a href="javascript:changeFontSize(-1)">Decrease Font Size</a>
You tin extend this to either all the HTML elements on your weblog or boundary it to exclusively the text sections. The font size is specified inwards pixels.

Related: Create a Printer Friendly Version of webpage alongside CSS

No comments:

Post a Comment