css - Why style effect remains after location.hash in Firefox? -


i creating program online psych experiment on web design. (please see code below) trying is, if user clicks on input box, invokes onfocus event, page jumps place (i.e. box comes top of page), , box has effect on outline indicate has focus.
implement using location.hash, anchor, , style.outline.

however, in firefox, once page jumps anchored point, outline style remains there though have event onblur remove outline style. know why happens , how fix it? related functions problem jump() , noeffect() in code.

this works in chrome , safari, not in firefox. (ie not working. ie not show outline style @ all. if know how fix in ie, please let me know too) preferably, want program used in major browsers.

thanks in advance!

---------code-----------

<html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript" >  function loadings() { var bcolor = "#000000 "; var bstyle = "solid "; var bthick = "2px ";  document.getelementbyid("one").innerhtml = "<div>userid:</div><div><input style='width: 80px; border: "+bthick+bstyle+bcolor+";'  id='us' name='us' type='text' /></div>"; document.getelementbyid("two").innerhtml = "<div>password:</div><div><input style='width: 80px; border: "+bthick+bstyle+bcolor+";'  id='pw' name='pw' onfocus='jump(\"one\", \"pw\");' onblur='noeffect(\"pw\")'; type='password' /></div>";  document.getelementbyid('us').focus(); }  function jump(str, id){     location.hash = str;     document.getelementbyid(id).style.outline = "red solid 2px";     //settimeout(noeffect(id), 1000); }  function noeffect(id){     document.getelementbyid("pw").style.outline = "green solid 5px"; }  </script> <style type="text/css"> input:focus {outline: orange solid 2px;} </style> </head>  <body onload = "loadings();"> <p> click password box. jump #pw (or somewhere else fine), <br/> , focus on password box (some effect happen on outline). <br/> if click userid box, want effect disappear, remains. how should fix? </p>  <table border="1">  <tbody>   <tr>    <td style="vertical-align:top;"><div id="one"> </div></td>    <td style="text-align: right; vertical-align:top;"><div id="two"></div></td>   </tr>   <tr>    <td style="vertical-align:bottom;"><div id="three"></div></td>    <td style="text-align: right; vertical-align:bottom;"><div id="four"></div></td>   </tr>  </tbody> </table> </body> </html> 

i'm not sure if fixes problem, location.hash includes # symbol, think should assign "#one" instead of "one".

also, in firefox have option of using onhashchange event change style when jump. https://developer.mozilla.org/en/dom/window.onhashchange


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -