0

Can I change font-size by javascript like use innerHTML or something else ?

<iframe frameborder="0" src="javascript:'<html></html>';" id="iframe1" title="" style="width: 100%;height: 416px;margin: 0px;padding: 0px;">
<!DOCTYPE html>
<html>
<head>
<style></style>
</head>
<body style="font-size:12px;"> HELLO WORLD </body></html>
</iframe>

It means when iframe load or focus, the font-size must change.

scycdpros
  • 33
  • 1
  • 5
  • Possible duplicate of [How to change FontSize By JavaScript?](https://stackoverflow.com/questions/5586703/how-to-change-fontsize-by-javascript) – Alok Mali Sep 20 '19 at 05:25

6 Answers6

0

You can add some JavaScript to change the font size.

document.body.style.fontSize = '15px'
GeorgeButter
  • 2,521
  • 1
  • 29
  • 47
0

visite w3schools.com where you can get more details with examples

document.body.style.fontSize="20px";

Prakash Karena
  • 2,525
  • 1
  • 7
  • 16
0

You can use getElementsByTagName for add style for body.

document.getElementsByTagName("body")[0].style.fontSize = "20px";

document.getElementsByTagName("body")[0].style.fontSize = "20px";
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<style></style>
</head>
<body style="font-size:12px;"> HELLO WORLD </body></html>
Pushprajsinh Chudasama
  • 7,772
  • 4
  • 20
  • 43
0

This is the code that will convert your all text into desired font-size.

document.onreadystatechange = function () {
    if (document.readyState == "complete") {
     var your-str = document.getElementsByTagName("body")[0];
     var obj-store-style-property = your-str.fontsize(12);
     document.getElementsByTagName("body").innerHTML = obj-store-style-property;
   }
  }
Kaleemullah
  • 446
  • 3
  • 8
0

$("#iframe1").contents().find("body").css('font-size','20px');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<iframe frameborder="0" src="javascript:'<html></html>';" id="iframe1" title="" style="width: 100%;height: 416px;margin: 0px;padding: 0px;">
<!DOCTYPE html>
<html>
<head>
</head>
<body style="font-size:12px;"> HELLO WORLD  </body></html>
</iframe>
satish mallick
  • 625
  • 5
  • 9
-1

Try:

document.body.style.fontSize="12px";
Ritesh Khandekar
  • 3,885
  • 3
  • 15
  • 30