How to set font family with javascript ONLY- no access to jquery, html, or css, only js -


i building print products efi digital storefront using directsmile, variable data program plugs in indesign , digital storefront. complex formatting of variable data fields can done within directsmile javascript.

i can add javascript formatting, there no css or html can work in conjunction js. add snippet of js variable data field, save , export file, , upload digital storefront.

javascript > variable data field > directsmile document > zipped product > digital storefront

right working on business card. displays phone numbers this:

office 123.456.7890
cell 123.456.7890
fax 123.456.7890

where words office, cell, , fax supposed in 1 font (8pt archer bold) , numbers supposed in (8pt graphik light). needs defined in javascript don't know how. i'm new this, , research isn't panning out- every method i've found seems require access html/css, don't have.

this javascript i've used in past format phone numbers preceding labels ("office" "cell" "fax") appear if associated phone number used customer, , format phone number itself:

function numbers(){      out = ""      num = var.gets("office_phone", "")       if(num.length>0) out += "office" + phone(num) + "\n";  else out = "" + out;      num = var.gets("cell_phone", "")         if(num.length>0) out += "cell" + phone(num) + "\n";  else out = "" + out;      num = var.gets("fax", "")                if(num.length>0) out += "fax" + phone(num) + "\n";  else out = "" + out;      return out;  }    function phone(number){      tmp = ""; div = ".";      if( number.length>0 ){          tmp = number.replace(/\d/g, "");          var len = tmp.length;          tmp = tmp.split("");          tmp.splice(len-7,0, div);          tmp.splice(len-3,0, div);          tmp = tmp.join("");      }      return tmp;  }

what can add/change have preceding label ("office" "cell" "fax") appear 8pt archer bold , phone numbers 8pt graphik light?

all appreciated. thank you

note: response applies standard html only

it not appear relevant directsmile requested in question. arriving looking setting fontfamily on plain html elements through vanilla javascript response may useful. othewise please ignore.

to set style attribute on item in javascript:

var el = document.getelementbyid('theelementid'); el.style.fontfamily = 'graphik light'; 

for work, need identify specific dom element ids target javascript at.

if have id block, may need extend concept identify items tag name within block. example, following apply font family style every span element in outer block id="blockid":

var block = document.getelementbyid('blockid'); var els = block.getelementsbytagname('span'); for(var in els){   if(els.hasownproperty(i)){     var el = els[i];     el.style.fontfamily = 'graphik light';   } } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -