Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Window Blur Event
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="NSA" data-source="post: 189880" data-attributes="member: 10034"><p>Hello!</p><p> </p><p>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.</p><p> </p><p>I put together a JsFiddle to show you how to do it.</p><p> </p><p>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.</p><p> </p><p>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.</p><p> </p><p>Here's the JsFiddle: <a href="http://jsfiddle.net/6NZWn/1/" target="_blank">http://jsfiddle.net/6NZWn/1/</a></p></blockquote><p></p>
[QUOTE="NSA, post: 189880, member: 10034"] 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: [url]http://jsfiddle.net/6NZWn/1/[/url] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Window Blur Event
Top