Make Browser Window Blink in Task Bar

Make browser window blink in task Bar

this won't make the taskbar button flash in changing colours, but the title will blink on and off until they move the mouse. This should work cross platform, and even if they just have it in a different tab.

newExcitingAlerts = (function () {
var oldTitle = document.title;
var msg = "New!";
var timeoutId;
var blink = function() { document.title = document.title == msg ? ' ' : msg; };
var clear = function() {
clearInterval(timeoutId);
document.title = oldTitle;
window.onmousemove = null;
timeoutId = null;
};
return function () {
if (!timeoutId) {
timeoutId = setInterval(blink, 1000);
window.onmousemove = clear;
}
};
}());

Update: You may want to look at using HTML5 notifications.

How do I make a Chrome extension's window blink in the taskbar?

Yes, it's possible with the windows API:

drawAttention

If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to false to cancel a previous draw attention request.

// You can pass -2 as windowId for the current window,
// or query tabs/windows to get the one you want
chrome.windows.update(windowId, {drawAttention: true});

Make Google Chrome Browser Icon Flash on task bar

Chrome only flashes when the browser announces an alert, so printing an alert with javascript could be a workaround for the intended result. Keep in mind it also only does this if you are not currently focused on chrome. Hit run and quickly tab out to see what I mean.

jQuery(document).ready(function($) { alert("Flash you Chrome, flash!");});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Make chrome icon on windows taskbar glow when chrome is minimized

What I needed was a tactic that can get the users attention when they receive a new message while the browser is minimized. I couldn't find a way for the icon on the task bar to blink but I found an alternative that still fills the need. @HariKrishnan gave a link that led to a couple of googling that made me discover Web Notifications. You can find a very simple tutorial here.

Cheers!


For future reference I added the tut here since its just a two step process . .

Step 1

Ask user to allow webkitNotifications (Same thing with the html5 geolocation)

function askPermission(){
webkitNotifications.requestPermission(testNotification);
}

Step 2

Creating a notification

function testNotification(){    
var notification = webkitNotifications.createNotification('IMAGE','TITLE','BODY');
notification.show();
}

(Note: Multiple notifications will stack)

Possible to flash a Browser window using Javascript?

@Hexagon Theory: Why would you ever rewrite the whole head element just to change the value of one element in the head? Your solution is horribly inefficient on multiple levels.

<html>
<head>
<link rel="icon" href="on.png" type="image/png" id="changeMe" />
<script type="text/javascript" src="flash.js"></script>
</head>
<body>
</body>
</html>

flash.js:

function Flasher(speed) {
var elem = document.getElementById('changeMe');

this.timer = setTimeout(function() {
elem.href = elem.href == 'on.png' ? 'off.png' : 'on.png';
}, speed);

this.stop = function() { clearTimeout(this.timer); }
}

/* sample usage
*
* var flasher = new Flasher(1000);
* flasher.stop();
*/

It didn't really have to be a class but it helped keep the global namespace clean. That's untested but if simply changing the href doesn't work for some reason, clone the link node, change the href and replace the old link with the cloned one.



Related Topics



Leave a reply



Submit