html - JavaScript change fontsize not working everywhere -
i have code:
function change_npsize() { document.getelementbyid("np_drag").style.fontsize = document.getelementsbyname("npsize").item(0).value; }; <input type="text" name="npsize" size="2" maxlength="2" value="<?=$userinfo->npsize; ?>" onchange="change_npsize()" /> <div id="drag-container" style="position:relative;font-family:<?=$userinfo->font?>;"> <div id="np_drag" style="color:<?=$userinfo->npcolor?>; font-size:<?=$userinfo->npsize?>px;" class="draggable np_drag" style="position:absolute;left:80px;"> .::[ nowplaying signature ]::. </div> </div>
that code working in ie. tried firefox , google chrome.
the proper usage of getelementsbyname()
(at least in firefox) is:
getelementsbyname("npsize")[0];
the following works (at least in chrome):
document.getelementbyid("np_drag").style.fontsize = document.getelementsbyname("npsize")[0].value + "px";
note + "px"
@ end; can’t set numeric value, need include appropriate unit in value.
Comments
Post a Comment