<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

      <title>Comments on: IE... you are my enemy! (At least when it comes to CSS/Javascript)</title>
      <link>http://ask.metafilter.com/31177/IE-you-are-my-enemy-At-least-when-it-comes-to-CSSJavascript/</link>
      <description>Comments on Ask MetaFilter post IE... you are my enemy! (At least when it comes to CSS/Javascript)</description>
	  	  <pubDate>Fri, 20 Jan 2006 07:53:27 -0800</pubDate>
      <lastBuildDate>Fri, 20 Jan 2006 07:53:27 -0800</lastBuildDate>
      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>

<item>
  	<title>Question: IE... you are my enemy! (At least when it comes to CSS/Javascript)</title>
  	<link>http://ask.metafilter.com/31177/IE-you-are-my-enemy-At-least-when-it-comes-to-CSSJavascript</link>	
  	<description>How the heck do I iterate through all a given div&apos;s style sheet in IE? This code works fine in mozilla, but IE can&apos;t get a grip on the style.length to start the loop...&lt;br&gt;
&lt;br&gt;
var ix = document.getElementById(&apos;playground&apos;).childNodes[i].style.length;&lt;br&gt;
while(ix--)&lt;br&gt;
  {&lt;br&gt;
  styleElement =  document.getElementById(&apos;playground&apos;).childNodes[i].style[ix];&lt;br&gt;
  styleAttribute = document.getElementById(&apos;playground&apos;).childNodes[i].style.getPropertyValue(styleElement);&lt;br&gt;
  logMessage(&apos;attribute: &apos; + styleElement + &apos; value: &apos; + styleAttribute );&lt;br&gt;
  }</description>
  	<guid isPermaLink="false">post:ask.metafilter.com,2008:site.31177</guid>
  	<pubDate>Fri, 20 Jan 2006 06:41:47 -0800</pubDate>
  	<dc:creator>ph00dz</dc:creator>
	
	<category>javascript</category>
	
	<category>css</category>
	
	<category>dhtml</category>
	
	<category>mozilla</category>
	
	<category>ie</category>
	
	<category>internetexplorer</category>
	
	<category>webdev</category>
	
</item>
<item>
  	<title>By: weston</title>
  	<link>http://ask.metafilter.com/31177/IE-you-are-my-enemy-At-least-when-it-comes-to-CSSJavascript#489227</link>	
  	<description>Hmmm. Accessing the style property as an array. I guess it&apos;s possible, given that objects in javascript are also hashes, but I&apos;m not sure about being able to iterate over them via numeric keys. &lt;br&gt;
&lt;br&gt;
This really works for you in Moz? Poking at this quickly in the &lt;a href=&quot;http://www.squarefree.com/shell/shell.html&quot;&gt;Javascript shell&lt;/a&gt;, I find that this:&lt;br&gt;
&lt;br&gt;
output = document.getElementById(&apos;output&apos;)&lt;br&gt;
output.style[5]&lt;br&gt;
&lt;br&gt;
Doesn&apos;t get me anything, even though there is indeed a div id&apos;d output on the page.&lt;br&gt;
&lt;br&gt;
There&apos;s also the issue that the style object may only give you back inline styles already set on the element/object, not the &lt;a href=&quot;http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/bcfc4aaea94a5a90/6176a6a7c0dcd19f?lnk=st&amp;q=notsew+computed+style+javascript&amp;rnum=1#6176a6a7c0dcd19f&quot;&gt;computed style&lt;/a&gt;.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.31177-489227</guid>
  	<pubDate>Fri, 20 Jan 2006 07:53:27 -0800</pubDate>
  	<dc:creator>weston</dc:creator>
</item>
<item>
  	<title>By: ph00dz</title>
  	<link>http://ask.metafilter.com/31177/IE-you-are-my-enemy-At-least-when-it-comes-to-CSSJavascript#489264</link>	
  	<description>&lt;pre&gt;&lt;br&gt;
&lt;br&gt;
cssTextArray = document.getElementById(&apos;playground&apos;).childNodes[i].style.cssText.split(&amp;quot;;&amp;quot;);&lt;br&gt;
ix = cssTextArray.length;&lt;br&gt;
while(ix--)&lt;br&gt;
  {&lt;br&gt;
  cssTextElementsArray = cssTextArray[ix].split(&amp;quot;:&amp;quot;);&lt;br&gt;
  styleElement = trim(cssTextElementsArray[0]).toLowerCase();&lt;br&gt;
  styleValue = trim(cssTextElementsArray[1]);&lt;br&gt;
  logMessage(&apos;element: &apos; + styleElement + &apos; value: &apos; + styleValue);&lt;br&gt;
  } // end while&lt;br&gt;
  &lt;br&gt;
// trim code from http://www.apriori-it.co.uk/Trim.asp&lt;br&gt;
function trim(trimValue)&lt;br&gt;
  {&lt;br&gt;
  if(trimValue.length &lt; 1)br&gt;
    {&lt;br&gt;
    return &amp;quot;&amp;quot;;&lt;br&gt;
    }&lt;br&gt;
  trimValue = RTrim(trimValue);&lt;br&gt;
  trimValue = LTrim(trimValue);&lt;br&gt;
  if(trimValue == &amp;quot;&amp;quot;)&lt;br&gt;
    {&lt;br&gt;
    return &amp;quot;&amp;quot;;&lt;br&gt;
    }&lt;br&gt;
  else&lt;br&gt;
    {&lt;br&gt;
    return trimValue;&lt;br&gt;
    }&lt;br&gt;
  } // end function&lt;br&gt;
    &lt;br&gt;
function RTrim(VALUE)&lt;br&gt;
  {&lt;br&gt;
  var w_space = String.fromCharCode(32);&lt;br&gt;
  var v_length = VALUE.length;&lt;br&gt;
  var strTemp = &amp;quot;&amp;quot;;&lt;br&gt;
  if(v_length &lt; 0)br&gt;
    {&lt;br&gt;
    return &amp;quot;&amp;quot;;&lt;br&gt;
    }&lt;br&gt;
  var iTemp = v_length -1;&lt;br&gt;
  &lt;br&gt;
  while(iTemp &amp;gt; -1)&lt;br&gt;
    {&lt;br&gt;
    if(VALUE.charAt(iTemp) == w_space)&lt;br&gt;
      {&lt;br&gt;
      }&lt;br&gt;
    else&lt;br&gt;
      {&lt;br&gt;
      strTemp = VALUE.substring(0,iTemp +1);&lt;br&gt;
      break;&lt;br&gt;
      }&lt;br&gt;
    iTemp = iTemp-1;&lt;br&gt;
    } //End While&lt;br&gt;
  return strTemp;&lt;br&gt;
  } //End Function&lt;br&gt;
&lt;br&gt;
function LTrim(VALUE)&lt;br&gt;
  {&lt;br&gt;
  var w_space = String.fromCharCode(32);&lt;br&gt;
  if(v_length &lt; 1)br&gt;
    {&lt;br&gt;
    return &amp;quot;&amp;quot;;&lt;br&gt;
    }&lt;br&gt;
  var v_length = VALUE.length;&lt;br&gt;
  var strTemp = &amp;quot;&amp;quot;;&lt;br&gt;
&lt;br&gt;
  var iTemp = 0;&lt;br&gt;
&lt;br&gt;
  while(iTemp &lt; v_length)br&gt;
    {&lt;br&gt;
    if(VALUE.charAt(iTemp) == w_space)&lt;br&gt;
      {&lt;br&gt;
      }&lt;br&gt;
    else&lt;br&gt;
      {&lt;br&gt;
      strTemp = VALUE.substring(iTemp,v_length);&lt;br&gt;
      break;&lt;br&gt;
      }&lt;br&gt;
    iTemp = iTemp + 1;&lt;br&gt;
    } //End While&lt;br&gt;
  return strTemp;&lt;br&gt;
} //End Function &lt;br&gt;
&lt;/&gt;&lt;/&gt;&lt;/&gt;&lt;/&gt;&lt;/pre&gt;</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.31177-489264</guid>
  	<pubDate>Fri, 20 Jan 2006 08:23:19 -0800</pubDate>
  	<dc:creator>ph00dz</dc:creator>
</item>
<item>
  	<title>By: mordecaibrown</title>
  	<link>http://ask.metafilter.com/31177/IE-you-are-my-enemy-At-least-when-it-comes-to-CSSJavascript#489449</link>	
  	<description>This should get you started. It iterates through all of the properties of the style. Be warned that not all properties of style are CSS properties (length being 1 example). I have additional example code regarding dynamically setting CSS styles from a project I am working on right now. Send me an email if you are interested.&lt;br&gt;
&lt;br&gt;
var cssStyles = document.getElementById(&apos;playground&apos;).childNodes[i].style;&lt;br&gt;
for (property in cssStyles )&lt;br&gt;
{&lt;br&gt;
	logMessage(property + &apos; = &apos; + cssStyles[property]);&lt;br&gt;
}</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.31177-489449</guid>
  	<pubDate>Fri, 20 Jan 2006 11:07:03 -0800</pubDate>
  	<dc:creator>mordecaibrown</dc:creator>
</item>
<item>
  	<title>By: ph00dz</title>
  	<link>http://ask.metafilter.com/31177/IE-you-are-my-enemy-At-least-when-it-comes-to-CSSJavascript#489512</link>	
  	<description>Thanks mordecaibrown... it&apos;s weird how different the results are in IE vs. Mozilla, isn&apos;t it?&lt;br&gt;
&lt;br&gt;
I think I&apos;ve got a pretty good grip on how to get/set specific values -- I just wanted to see if there was an easy way to read out all that data at once...</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.31177-489512</guid>
  	<pubDate>Fri, 20 Jan 2006 11:48:49 -0800</pubDate>
  	<dc:creator>ph00dz</dc:creator>
</item>
<item>
  	<title>By: ph00dz</title>
  	<link>http://ask.metafilter.com/31177/IE-you-are-my-enemy-At-least-when-it-comes-to-CSSJavascript#490299</link>	
  	<description>by the way... I think I forgot to explain it, but the code I posted above is how I got around the problem.&lt;br&gt;
&lt;br&gt;
If you need something that can read back the exact set of css values you&apos;ve set for a div in both IE and Firefox, that&apos;ll work. However, the values aren&apos;t perfect, as weston pointed out. Even &apos;z-index&apos; is all crazy... you&apos;ll see, if you dig into it more.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.31177-490299</guid>
  	<pubDate>Sat, 21 Jan 2006 17:25:37 -0800</pubDate>
  	<dc:creator>ph00dz</dc:creator>
</item>

    </channel>
</rss>
