NSA
sudo apt-get thefuckout.tar.gz
- Dec 9, 2011
- 715
- 86
Hello!
So when Facebook added the sounds to the chat function, I always wondered how they made it so that when you were looking at the chat, the sound didn't play... but if you were looking away, it did.
I put together a JsFiddle to show you how to do it.
When you click on the text, the music will start playing (as long as you're looking at the page) but when you switch tabs, the music will pause.
You could add an if statement in there with an ajax request so that when the ajax response comes, it will check if the user is looking at the screen. If they are, don't play the music, however if they're not, play it.
Here's the JsFiddle:
So when Facebook added the sounds to the chat function, I always wondered how they made it so that when you were looking at the chat, the sound didn't play... but if you were looking away, it did.
I put together a JsFiddle to show you how to do it.
When you click on the text, the music will start playing (as long as you're looking at the page) but when you switch tabs, the music will pause.
You could add an if statement in there with an ajax request so that when the ajax response comes, it will check if the user is looking at the screen. If they are, don't play the music, however if they're not, play it.
Here's the JsFiddle:
You must be registered for see links