$q.appVisible is firing twice on clicking the tab
-
This post is deleted! -
tried a lot of different browsers but I see no popup or and kind of UI interface except some text.
-
@dobbel after running codepen, switch to another tab to loose visibility, then come back to codepen tab. it will fire new tab opening on getting visibility, if not, then check the right most area of addressbar showing pop-up blocked sign.
-
@jitendra16 I think this is a browser bug that window.open is toggling the app visibility. What exactly are you trying to accomplish? You may be able to achieve it with something like this:
var new_window = window.open('some url') new_window.onbeforeunload = function(){ /* my code */ }
https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript
-
@beets No, its not because of browser bug as I tried to console log ‘Date.now()’ and found out that ‘$q.appVisible’ watch code is called twice.
-
@jitendra16 I checked in your codepen, and I don’t get the same results without
window.open
. Keep in mind, the watch handler does fire twice, once when it becomes not visible, and once when it becomes visible again. So maybe if you had the console.log outside theif(state)
condition is why you saw it fire twice.watch: { '$q.appVisible' (state) { if(state && this.counter < 9) { console.log(Date.now()) } this.counter++ } }
-
@beets Yes, you are right. Let me try your suggestion.
var new_window = window.open('some url') new_window.onbeforeunload = function(){ /* my code */ }
-
@jitendra16 That code is just a starting point, btw. You may want to add more details on what you actually want to accomplish. See https://xyproblem.info/
I assume you want when a popup is closed to open another, but are these links on the same domain as yours? If so, onbeforeunload may not work, you’ll have to experiment a bit.
-
@beets Sure. Actually, i have a followup list of persons with their WhatsApp number, so I am triggering prefilled msgs to Whatsapp API. So the flow is like this.
- user starts the sequence on btn click
- App open WA API for 1st record.
- user send the msg on whatsapp App
- Comes back to our App
- App open WA API for 2nd record
so on.
window.open(`https://wa.me/91${bulk[this.WAsequence].number}?text=${encodeURIComponent(bulk[this.WAsequence].message)}`