0

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.

Sumit Patel
  • 4,530
  • 1
  • 10
  • 28
  • Which browser are you testing in? – yunzen Jul 18 '19 at 07:24
  • currently working on chrome but its not working on any browser. – Sumit Patel Jul 18 '19 at 07:32
  • I made up this experiment in codepen: https://codepen.io/HerrSerker/pen/5c2fc4eaab757284012801ce27d4a8e2 I works in Chrome, Firefox, Edge, IE11 on Windows. I can focus on all the new windows from the source window. But, and that might be the case with your issue: if you reload the originating window, all the references to your new window will be lost, and it won't work anymore. – yunzen Jul 18 '19 at 07:33
  • Yes you are right because i am connecting to call server new window will disconnect . – Sumit Patel Jul 18 '19 at 07:43
  • maybe this answer helps: https://stackoverflow.com/a/21024022/476951 – yunzen Jul 18 '19 at 08:36

2 Answers2

1

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

Philipp
  • 475
  • 4
  • 18
0

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.