Forum Moderators: open

Message Too Old, No Replies

Detecting if an element loses or gains focus

         

fintan

3:10 pm on May 15, 2006 (gmt 0)

10+ Year Member



Hi I'm building an app where I need to know where a user is on a page. I need to know if an element has focus or loses focus. Will the onfocus and onblur work outside of a form? Thanks

fintan.

coopster

6:22 pm on May 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sure it will.

fintan

8:49 am on May 16, 2006 (gmt 0)

10+ Year Member



Thanks again coopster I have some of this working but the onblur won't work say if I click on the body or another element. Am I going about this the right way?

function Collapse(size){
size.setAttribute("style", "height : 200px;");
size.style.cssText = "height : 200px;";

}

function Expand(size){
if(size.clientHeight == "200"){
size.setAttribute("style", "height : 800px;");
size.style.cssText = "height : 800px;";
}
else{
resize = Collapse(size);
}
}

<div class="call" id="call" onmouseover="style.backgroundColor='#F1F5F9';" onmouseout="style.backgroundColor='#FFFFFF'" title="Click once to see call details" onclick="Expand(this);calldetails('.$rslt['HD_ID'].');" onblur="Collapse(this);">