Create a gist now

Instantly share code, notes, and snippets.

JavaScript function that displays a toast notification in Universal Windows Apps. For Web Apps, Hosted Web Apps and WebView with Windows Runtume Access.
function showToast () {
if(typeof Windows !== undefined) {
var notifications = Windows.UI.Notifications;
var template = notifications.ToastTemplateType.toastImageAndText01;
var toastXml = notifications.ToastNotificationManager.getTemplateContent(template);
var toastTextElements = toastXml.getElementsByTagName("text");
toastTextElements[0].appendChild(toastXml.createTextNode("Toast from Codepen"));
var toastImageElements = toastXml.getElementsByTagName("image");
toastImageElements[0].setAttribute("src", "");
toastImageElements[0].setAttribute("alt", "red graphic");
var toast = new notifications.ToastNotification(toastXml);
var toastNotifier = notifications.ToastNotificationManager.createToastNotifier();;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment