Blazor.Notifications icon indicating copy to clipboard operation
Blazor.Notifications copied to clipboard

Adding opening tab on click notification

Open nikminer opened this issue 9 months ago • 0 comments

Add the ability to open a tab or window to a new page when clicking on a notification, as in the documentation example

https://developer.mozilla.org/en-US/docs/Web/API/Notification/click_event

You can add the url property to the NotificationOptions class.

Then in script.js change the opening function create like:

export function create(title, options) {
    var notify = new Notification(title, options);
    if (options.URL != null) {
        notify.onclick = (event) => {
            event.preventDefault();
            window.open(options.url, "_blank");
            event.target.close(); // close notifycation
        };
    }
    return notify;
}

nikminer avatar Apr 22 '25 11:04 nikminer