ginerjm Posted September 4, 2011 Share Posted September 4, 2011 ok - a followup to my previous post I'm now using this function to return some css info (none of it inline styles). Works great (thru the help I received on earlier post) for IE device, but the btn and paragraph sizes don't come back to me for an iDevice(Safari). (I get 'null'.) function ShowSizes() { var btn = document.getElementById("btn"); var para = document.getElementById("para"); var div1 = document.getElementById("first_div"); var div2 = document.getElementById("second_div"); var dvc = document.getElementById("devicefld").value; var i_ar=("iPhone","iPad"); if (dvc.match(i_ar)) { var input_sz = window.getComputedStyle(btn, "").getPropertyValue("fontSize"); var p_sz = window.getComputedStyle(para, "").getPropertyValue("fontSize"); } else { var input_sz = btn.currentStyle.fontSize; var p_sz = para.currentStyle.fontSize; } alert("v3Checking Input size is "+input_sz + " para sz is "+p_sz + " First div W: "+div1.offsetWidth + " H: "+div1.offsetHeight + " 2nd div W: "+div2.offsetWidth+ " H: "+ div2.offsetHeight); } Quote Link to comment https://forums.phpfreaks.com/topic/246424-fontsize-from-an-idevice/ Share on other sites More sharing options...
nogray Posted September 4, 2011 Share Posted September 4, 2011 If you use getPropertyValue, you would need to use the css rule as in css (with a -) e.g window.getComputedStyle(btn, null).getPropertyValue('font-size'); or window.getComputedStyle(btn, null).fontSize; Quote Link to comment https://forums.phpfreaks.com/topic/246424-fontsize-from-an-idevice/#findComment-1265436 Share on other sites More sharing options...
ginerjm Posted September 4, 2011 Author Share Posted September 4, 2011 another little nuance of learning JS - thanks!! While waiting I did find this on javascriptkit.com: function getStyle(el, cssprop) { if (el.currentStyle) //IE return el.currentStyle[cssprop]; else if (document.defaultView && document.defaultView.getComputedStyle) //Firefox return document.defaultView.getComputedStyle(el, "")[cssprop]; else //try and get inline style return el.style[cssprop]; } [\code] This seems to work for IE as well as both my iPhone and iPad. Quote Link to comment https://forums.phpfreaks.com/topic/246424-fontsize-from-an-idevice/#findComment-1265446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.