Home Ask Login Register

Developers Planet

Your answer is one click away!

Lenny February 2016

Target style null when cursor leave the screen on Firefox

I have some issue with Firefox when my cursor leave the current window.

In the sample of the code I release the old target style, which works fine on IE and Chrome, but not on Firefox if my cursor leave the current window the "instance.Target.style" is undefined.

Have I done something wrong, or Firefox choose to have a different behaviour ?

function WidgetGrid_MouseMove(domEvent,instance)
    // Get the target element
    var target = domEvent.target;

    // Release the old target
    if (instance.Target && instance.Target != target)
        instance.Target.style.cursor = "";

    // Set the new target
    instance.Target = domEvent.target;

    // Do other thing


Korgrue February 2016


instance.Target.style.cursor = null;

Different browsers check for empty variables differently. That is why it is good practice to do something like:

var instance = instance.Target.style.cursor;

if (instance === "" || instance === null){
   //do something.....

Post Status

Asked in February 2016
Viewed 1,361 times
Voted 14
Answered 1 times


Leave an answer

Quote of the day: live life