Reputation: 4638
I have create a custom call messenger which is working perfectly fine without any issue.
I need a suggestion for when i minimize the messenger browser window and that time if any call comes in i want to show some kind of indication in terms of pop out that window or highlight.
I have tried window.focus
which work if the window is not focus but when it's minimized it's not working.
Is there any other way which way i can show any indication to particular window.
Upvotes: 0
Views: 903
Reputation: 475
You need to take a look at javascript Notifications for that
Additionaly you could change the document.title
or the favicon to indicate that this tab has some notifications like YouTube does it for example with the counter of notifications in the title
Upvotes: 1
Reputation: 1
The open call returns a reference to the new window. It can be used to manipulate it’s properties, change location and even more.
In this example, we generate popup content from JavaScript:
let newWin = window.open("about:blank", "hello", "width=200,height=200");
newWin.document.write("Hello, world!");
And here we modify the contents after loading:
let newWindow = open('/', 'example', 'width=300,height=300')
newWindow.focus();
alert(newWin.location.href); // (*) about:blank, loading hasn't started yet
newWindow.onload = function() {
let html = `<div style="font-size:30px">Welcome!</div>`;
newWindow.document.body.insertAdjacentHTML('afterbegin', html);
};
Please note: immediately after window.open, the new window isn’t loaded yet. That’s demonstrated by alert in line (*). So we wait for onload to modify it. We could also use DOMContentLoaded handler for newWin.document.
Upvotes: 0