Created
July 13, 2012 08:52
-
-
Save damienklinnert/3103743 to your computer and use it in GitHub Desktop.
a simple test for html notifications from html5rocks at http://www.html5rocks.com/en/tutorials/notifications/quick/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>notifications</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script> | |
$(function () { | |
if (window.webkitNotifications) { | |
console.log('Notifications are supported!'); | |
console.log(webkitNotifications); | |
} else { | |
console.log('Notifications are not supported!'); | |
} | |
var createNotificationInstance = function (options) { | |
if (options.notificationType === 'simple') { | |
return window.webkitNotifications.createNotification( | |
'icon.png', | |
'Notification title', | |
'Notification content ...' | |
); | |
} else if (options.notificationType === 'html') { | |
return window.webkitNotifications.createHTMLNotification('http://damienklinnert.de'); | |
} | |
}; | |
$('button').click(function (e) { | |
if (window.webkitNotifications.checkPermission() == 0) { | |
createNotificationInstance({notificationType:'simple'}).show(); | |
} else { | |
window.webkitNotifications.requestPermission(function () {}); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<button>alert</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment