TEXT   56

Zoom js

Guest on 16th July 2022 03:55:36 PM

  1. var targettag = new Array('p'); //get all tags for //
  2. var sizes = new Array('10px','12px','14px','16px','18px','20px','22px','24px','26px');
  3. var initialSize = 2;
  4. function changeSize(IdTarget,action ){
  5.   if (!document.getElementById) return
  6.   var selected = null,size = initialsize,i,j,targettags;
  7.   size += action;
  8.   if ( size < 0 ) size = 0;
  9.   if ( size > 6 ) size = 6;
  10.   initialsize = size;
  11.   if ( !( selected = document.getElementById( idTarget ) ) ) selected = document.getElementsByTagName( idTarget )[ 0 ];
  12.   selected.style.fontSize = sizes[ size ];
  13.   for ( i = 0; i < tagTarget.length; i++ ){
  14.     tagsTarget = selected.getElementsByTagName( tagTarget[ i ] );
  15.     for ( j = 0; j < tagsTarget.length; j++ ) tagsTarget[ j ].style.fontSize = sizes[ size ];
  16.   }
  17. }

Raw Paste


Login or Register to edit or fork this paste. It's free.