Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy doesn't initial page focus change input field to Green on Google Chrome?
    primarykey
    data
    text
    <p>Why doesn't initial page focus doesn't change input field to Green on Google Chrome? I probably have to dig up the rgb stuff, don't I?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="jquery-1.6.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function Change(obj, evt) { if (evt.type == "focus") { obj.style.borderColor = "black"; obj.style.backgroundColor = "#90EE90"; // light green on focus } else if (evt.type == "blur") { obj.style.borderColor = "white"; obj.style.backgroundColor = "#7AC5CD"; // light blue on blur } } jQuery(document).ready(function() { jQuery("#Txt1").focus(); }); &lt;/script&gt; &lt;style type="text/css"&gt; .InputField { color: black; font-size: 12px; font-weight: bold; background-color: #7AC5CD; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;input id="Txt1" runat="server" class="InputField" onfocus="Change(this, event)" onblur="Change(this, event)" /&gt;&lt;br /&gt; &lt;input id="Txt2" runat="server" class="InputField" onfocus="Change(this, event)" onblur="Change(this, event)" /&gt;&lt;br /&gt; &lt;input id="Txt3" runat="server" class="InputField" onfocus="Change(this, event)" onblur="Change(this, event)" /&gt;&lt;br /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>================</p> <h1>8/8/2011 update</h1> <p>Sorry I wasn't specific enough on this one. I will write a new question with more details.. by just changing my initial code to use jQuery code, I can get it to work. I'll up-vote everyone and mark someone's as the answer just after I post my question containing "Green" and "Google Chrome" since you were all so helpful in the first round. That way you'll be notified immediately and can begin working on my actual question with real application code. The next one will be a little tougher. :-)</p> <p>Early clue ==> If I put an alert in just before setting focus or calling .focus() with jQuery, and click OK on the JavaScript Alert, it turns green. If I leave the Alert message out, the background-color doesn't change to green.</p> <p>===================</p> <h1>8/9/2011 update</h1> <p>Asked a new question:</p> <p><a href="https://stackoverflow.com/questions/7004143/why-isnt-page-jquery-focus-event-changing-background-color-style-to-green-in-go">Why isn&#39;t page jQuery .focus event changing background-color style to green in Google Chrome after redirect?</a></p>
    singulars
    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.
 

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