Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:05:35+00:00 2026-06-14T22:05:35+00:00

So basically I have a single page website with a whole bunch of hidden

  • 0

So basically I have a single page website with a whole bunch of hidden Vimeo videos. I need all the videos to pause when not displayed.

So far I’m able to pause one video when clicking on a specific anchor tag, but I want to be able to pause all the videos by clicking any of the a tags.

I tried many different things, but with my limited knowledge of JavaScript, I feel I’m out of my depth.

Any pointers would be very much appreciated.

<script>
function showonlyone(thechosenone) {
var newboxes = document.getElementsByTagName("div");
for(var x=0; x<newboxes.length; x++) {
name = newboxes[x].getAttribute("name");
if (name == 'newboxes') {
if (newboxes[x].id == thechosenone) {
newboxes[x].style.display = 'block';
}
else {
newboxes[x].style.display = 'none';
}}}}
</script>

<div name="newboxes" id="newboxes0" style="display: block;">
<iframe id="player" src="http://player.vimeo.com/video/53407474?api=1&player_id=player" width="800" height="450" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
<div name="newboxes" id="newboxes0" style="display: none;">
<iframe id="player" src="http://player.vimeo.com/video/53855813?api=1&player_id=player" width="800" height="450" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
<div name="newboxes" id="newboxes0" style="display: none;">
<iframe id="player" src="http://player.vimeo.com/video/19780095?api=1&player_id=player" width="800" height="450" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>

<a name="button" id="button1" href="javascript:showonlyone('newboxes0');"><span></span></a>
<a name="button" id="button2" href="javascript:showonlyone('newboxes1');"><span></span></a>
<a name="button" id="button3" href="javascript:showonlyone('newboxes2');"><span></span></a>

<script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>
<script>
function ready(player_id) {
var player = $f(player_id);
pauseButton = document.getElementById('button1');
pauseButton.addEventListener('click', function() {
player.api('pause');
});}
window.addEventListener('load', function() {
$f(document.getElementById('player')).addEvent('ready', ready);
});
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:05:35+00:00Added an answer on June 14, 2026 at 10:05 pm

    Well one of the things I notice right off the back is that you have multiple ID that are the same. ID’s are supposed to be unique.Check out the jsFiddle.

    So I re-wrote your html to be like this

    <div name="newboxes" id="newboxes0" style="display: block;">
        <iframe id="player0" src="http://player.vimeo.com/video/53407474?api=1&player_id=player" width="800" height="450" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    </div>
    <div name="newboxes" id="newboxes1" style="display: none;">
        <iframe id="player1" src="http://player.vimeo.com/video/53855813?api=1&player_id=player" width="800" height="450" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    </div>
    <div name="newboxes" id="newboxes2" style="display: none;">
        <iframe id="player2" src="http://player.vimeo.com/video/19780095?api=1&player_id=player" width="800" height="450" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    </div>
    
    <a name="button" id="button0" href="javascript:showonlyone('newboxes0');"><span>Button1</span></a>
    <a name="button" id="button1" href="javascript:showonlyone('newboxes1');"><span>Button2</span></a>
    <a name="button" id="button2" href="javascript:showonlyone('newboxes2');"><span>Button3</span></a>​
    

    Than I updated your JavaScript to look like this

    function showonlyone(thechosenone) {
        var newboxes = document.getElementsByName("newboxes"), x=0;
    
        for(var x = 0; x < newboxes.length; x++) {
            if (newboxes[x].id == thechosenone) {
                newboxes[x].style.display = 'block'; 
                var strPlayerID = newboxes[x].id.replace("newboxes", "player"); 
                var iframe = $('#'+strPlayerID)[0], player = $f(iframe);
                player.api('play');  
            } else {
                newboxes[x].style.display = 'none'; 
                var strPlayerID = newboxes[x].id.replace("newboxes", "player"); 
                var iframe = $('#'+strPlayerID)[0], player = $f(iframe);
                player.api('pause'); 
            }
        }
    }
    

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a single page on my site that I want any php
Basically I have a single page site that scrolls when the user clicks on
I have a single page that I need to on occasion asynchronously check the
I have basic single page website with the normal Google Analytic code: var _gaq
I have a website built with jquery mobile(Single page). I have something like a
I have a large, dynamically generated, single page website that heavily relies on javascript.
I basically have 7 select statements that I need to have the results output
I am thoroughly stumped on this one. Basically, I have an MVC page with
I have an ASP.NET website and from one of the web pages I need
Ok Soo I have 3 Sites. All need to store a cookie that each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.