Jump to content

Recommended Posts

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);
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/246424-fontsize-from-an-idevice/
Share on other sites

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.  

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.