You can use document.activeElement
to check if the element has indeed lost focus in DOM. (Browser compatibility is quite wide as well.)
Your code could look like this:
HTML
<input type="text" onblur='blurred(this);' />
JS
function blurred(elem) {
if (elem != document.activeElement) {
alert("Bye !");
}
}
See, also, this short demo.