Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm having a hard time understanding exactly what your question is, but it looks like Chrome can read <code>.style.display</code> properties just fine. I just threw the following code into an HTML template and loaded it in Chrome 10:</p> <pre><code>&lt;div id="div1"&gt; &lt;/div&gt; &lt;div id="div2" style="display: block;"&gt; &lt;/div&gt; &lt;div id="div3" style="display: inline;"&gt; &lt;/div&gt; &lt;div id="div4" style="display: none;"&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; alert(document.getElementById("div1").style.display); alert(document.getElementById("div2").style.display); alert(document.getElementById("div3").style.display); alert(document.getElementById("div4").style.display); document.getElementById("div1").style.display = "none"; alert(document.getElementById("div1").style.display); &lt;/script&gt; </code></pre> <p>The code produced 5 'alert' boxes with the following output:</p> <ul><li></li><li>block</li><li>inline</li><li>none</li><li>none</li></ul> <p>So it seems Chome reads this property just fine.</p> <p>Maybe the issue is that the webpage on which you're running your greasemonkey script is behaving differently in Chrome than in Firefox? Could it be that the ID of the element is different, or the element is being removed from the DOM instead of just being hidden? What would happen if you modified your function with some more checks, kinda like this?</p> <pre><code>function readTest() { el = document.getElementById('extra'); if(el) { GM_log(extraFlag); GM_log(el.style.display); if (el.style.display &amp;&amp; (el.style.display != 'none') &amp;&amp; (!extraFlag)) { alert('extra'); extraFlag = true; } else if ((el.style.display == 'none') || !el.style.display) { extraFlag = false; } } else { GM_log(extraFlag); GM_log("element not present"); extraFlag = false; } } </code></pre> <p>Does that help? If not, is there any other reason you could think of why el.style.display wouldn't evaluate properly in Chrome?</p> <p>It might help if we knew more about what you're trying to do with your script, and possibly what web page or code you're trying to run this on.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload