Reputation: 303
I am using the notifications described here http://code.google.com/chrome/extensions/notifications.html for a chrome extension.
Is there any way to overwrite the behaviour of the X button (close button) which is added by default? or can I disable it?
Upvotes: 1
Views: 3679
Reputation: 348992
The base layout of the notification popup cannot be modified.
There's no way to prevent the notification from being closed. Though not recommended, you can bind an onclose
event, which is fired when the notification is destroyed.
I've created a demo which shows a semi-persistent notification : http://jsfiddle.net/n385r/
In a Chrome extension, the "notifications"
permission has to be set in the manifest file. Then, a semi-persistent notification popup can be added as follows:
(function repeat() {
// Assume that /icon.png exists in the root of your extension
webkitNotifications.createNotification('/icon.png', 'Title', 'Message.');
note.onclose = function() {
// On close, repeat:
repeat();
};
note.show();
})(); // Start the notification
My interactive demo ( http://jsfiddle.net/n385r/ ) contains more details, and the notifications can be removed. The previously shown code keeps showing notifications, until the user disabled the extension, or shuts down Chrome. As you can imagine, that's not user-friendly, and you should not use a semi-persistent notification.
Upvotes: 4