文档标题不会停止闪烁

Document title won't stop blicking

我正在尝试让文档标题在收到消息时闪烁。我能够让标题正常闪烁,但是我 运行 遇到的问题是它不会停止。理想情况下,当鼠标移动时闪烁会停止,但我不确定为什么我的 onmousemove 处理程序无法正常工作。我使用的浏览器是 IE 11.

function titleAlert(message) { 
      var alertId, oldTitle = document.title;
      alertId = setInterval(function(){
           document.title = document.title == message ? oldTitle : message;
      }, 1500);
            
      var clear = function() {
          clearInterval(alertId);
          document.title = oldTitle;
          oldTitle = alertId = null;
      };
            
      return function() {   
           //also tried document.onmousemove
           window.onmousemove = clear;
      };
}  

您刚刚返回了一个函数的定义,但 运行 它没有返回。

    return (function() {   
       //also tried document.onmousemove
       window.onmousemove = clear;
    })();