Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.location.href - Link in new tab [duplicate]

Tags:

javascript

var notification = new Notification(theTitle, options);
notification.onclick = function() { 
    window.location.href = theLink; //redirects to the specified link
};

I am trying to open a new tab by clicking the notification box. Using the above code the redirection works fine. But I want to open the link in a new tab. How Can I do this?

like image 915
Anoop Mayampilly Muraleedharan Avatar asked Apr 06 '26 16:04

Anoop Mayampilly Muraleedharan


2 Answers

notification.onclick = function() { 
    window.open(theLink);
};
like image 147
Donald Wu Avatar answered Apr 08 '26 06:04

Donald Wu


try window.open("page url") hope it works

like image 28
Saurabh Gupta Avatar answered Apr 08 '26 04:04

Saurabh Gupta