google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Hướng dẫn dùng JavaScript để thay đổi kích cỡ chữ trên web Trong bài viết hướng dẫn sử dụng JavaScript khá ngắn gọn này, Nurani sẽ chỉ bạn cách dùng vài đoạn mã đơn giản để thay đổi kích cỡ chữ trên trang web của mình chỉ với một vài cú nhấn chuột.


Nhãn: hướng dẫn, thay đổi, kích cỡ, cỡ chữ

Miễn phí web hosting 1 năm đầu tại iPage



Nếu bạn vẫn còn đang tìm kiếm một nhà cung cấp hosting đáng tin cậy, tại sao không dành chút thời gian để thử với iPage, chỉ với không quá 40.000 VNĐ/tháng, nhưng bạn sẽ được khuyến mãi kèm với quà tặng trị giá trên 10.000.0000 VNĐ nếu thanh toán cho 24 tháng ~ 900.000 VNĐ?

Có trên 1 triệu khách hàng hiện tại của iPage đã & đang hài lòng với dịch vụ, tuyệt đối chắc chắn bạn cũng sẽ hài lòng giống họ! Quan trọng hơn, khi đăng ký sử dụng web hosting tại iPage thông qua sự giới thiệu của chúng tôi, bạn sẽ được hoàn trả lại toàn bộ số tiền bạn đã sử dụng để mua web hosting tại iPage. Wow, thật tuyệt vời! Bạn không phải tốn bất kì chi phí nào mà vẫn có thể sử dụng miễn phí web hosting chất lượng cao tại iPage trong 12 tháng đầu tiên. Chỉ cần nói chúng tôi biết tài khoản của bạn sau khi đăng ký.

Nếu muốn tìm hiểu thêm về ưu / nhược điểm của iPage, bạn hãy đọc đánh giá của ChọnHostViệt.com nhé!
Thử iPage miễn phí cho năm đầu tiên NGAY

Actually, almost all browsers have a feature to control the characters on the web pages you visit, by pressing the Ctrl key together with + (to zoom in) or - (to zoom out). But there is one other way of adding such a function "dynamic font size" on your site using javascript.

Here is a script that can be used to facilitate the visitors to control the font size of text on each page of your website/blog. This will be very useful for readers who struggle with small letters, and allow the person to enlarge the font size of your writing, so they are easier to read.

<script type="text/javascript">
var min=8;
var max=18;
function zoominLetter() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function zoomoutLetter() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
</script>

The script above will change the font size of text within the paragraph (tag <p>). If you want to use another tag, you can change the getElementsByTagName('p');

Of course, this script only works on the page with pixel sized fonts (letter-sized pixels (px)) compared with relative sized fonts (the relative size of the letters like: "em" and "%"). In addition, if the script does not find the font size of a paragraph, it will use the standard size, which is 12px.

How To Use :

Enter the above script on your blog page (either by typing in the tag <head> or by using .js file external and import). To call the function zoominLetter and zoomoutLetter you can use the following HTML code:

<a href="/javascript/article/Using_JavaScript_to_Change_Your_Web_Page_Font_Size.php/javascript:zoominLetter();">A</a>
<a href="/javascript/article/Using_JavaScript_to_Change_Your_Web_Page_Font_Size.php/javascript:zoomoutLetter();">a</a>

tips: You can change the text A | a with other signs, or replace it with a picture by using tags <img>.

iPhoneKer.com
Save up to 630$ when buy new iPhone 15

GateIO.gomymobi.com
Free Airdrops to Claim, Share Up to $150,000 per Project

https://tooly.win
Open tool hub for free to use by any one for every one with hundreds of tools

chatGPTaz.com, chatGPT4.win, chatGPT2.fun, re-chatGPT.com
Talk to ChatGPT by your mother language

Dall-E-OpenAI.com
Generate creative images automatically with AI

AIVideo-App.com
Render creative video automatically with AI

JavaScript theo ngày


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web