Generally there is no way anyone could know if you are online if you set status to invisible mode, but there is a small simple trick though.
Below is a trick to know if a person is logged in at an invisible mode.
You just need to follow below 3 steps..
Step 1. You login to Gtalk/Gmail chat as usual.
Step 2. Set the chat as 'off the record' with target user. This can be done by clicking on the inverted triangle button in chat window as follow.
Step 3. Now try sending chat to that target user when he is invisible or offline, you could say a 'hi'
-- If the target user is invisible, then he will receive your chat message.
But if the target user is not actually logged in then you would receive a alert message back ".... can't receive messages right now."
This really works, try it for your self...