how to make video only when tab is active

Discussion in 'HTML & JavaScript' started by Mutikasa, Nov 6, 2012.

  1. Mutikasa

    Mutikasa Power Member

    Joined:
    May 23, 2011
    Messages:
    579
    Likes Received:
    207
    Hi,
    I want to make this: video on website which plays only when the tab is active and counter which checks the mouse movements and if 30 sec there's no mouse movement the video stops.
    Basically, I want to force users to watch this video.
    tnx
     
  2. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,875
    Likes Received:
    12,641
    Occupation:
    Potentate
    Location:
    Asuncion
    Use jQuery - track mouse movement and then remove the video from the DOM if it 's not moving.
     
    • Thanks Thanks x 1
  3. berkolish

    berkolish Newbie

    Joined:
    Oct 2, 2012
    Messages:
    21
    Likes Received:
    2
    Yes, this would be pretty easy to do with Jquery or plain Javascript.