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 8001017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:58:35+00:00 2026-06-04T15:58:35+00:00

I am attempting to hide a DIV once a embedded Youtube video is finished.

  • 0

I am attempting to hide a DIV once a embedded Youtube video is finished. My platform is Drupal 7.x an I am using JQuery to show and hide the div. I am having troubles getting the onYouTubePlayerReady function to fire which prevents all this from happening. All files are on my webserver, I am not trying this locally as YouTube explains it does not work locally ( http://goo.gl/5qeKC )

My head section:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript" src="http://dev.mydomain.com/mytheme/site/sites/all/themes/mytheme/js/hfbusiness.js?m4hr22"></script>

In the hfbusiness.js file I have the following (this file is loading and working as I can fire a javascript alert which displays):

function onYouTubePlayerReady(id) {
    console.log("onYouTubePlayerReady() Fired!");
    var player = $("#youtube_player").get(0);
  }

Index.php contains:

<div class="marketing_video">
<iframe id="ytplayer" type="text/html" width="640" height="360" src="http://www.youtube.com/embed/hIaqCG8O5uU?version=3&enablejsapi=1&rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>

The video shows and plays without a problem with the defined options in the iframe. However, the YouTubePlayerReady function is never fired. I am beating my head against the wall on this, so far I have only accomplished a headache.

Thank you for any help.

  • 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-04T15:58:37+00:00Added an answer on June 4, 2026 at 3:58 pm

    I was able to get around the problem by using swfobject.js instead of the iFrame. I am wondering if the iFrame would let me do the same if I figured out a way to allowScriptAccess as below. If anyone knows the answer to this question, I would still appreciate an answer.

    In my index file:

    <script type="text/javascript">
        var params = { allowScriptAccess: "always" };
        var atts = { id: "myytplayer" };
        swfobject.embedSWF("http://www.youtube.com/v/hIaqCG8O5uU?enablejsapi=1&playerapiid=ytplayer&version=3", "ytapiplayer", "425", "356", "8", null, null, params, atts);
    
      </script>
    

    hfbusiness.js

    var $hfjq = jQuery.noConflict()
    
    function onYouTubePlayerReady(id) {
        var player = document.getElementById("myytplayer");
        player.addEventListener('onStateChange', 'playerState');
    }
    
    function playerState(state) {
        if(state == 0) {
            $hfjq(".marketing_video").hide();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting a one page design using loads of jQuery. I have a
I am attempting to hide some rows in an excel sheet using C#. but
I am attempting to use AJAX in jQuery to load content to a div,
I am attempting to hide certain elements using the combination of keyup with contains.
I am attempting to show/hide an overlay on blog articles when the user hovers
I am attempting to hide the document name from the user by using a
I'm attempting to hide all li 's within a div which is dynamically generated
Attempting to change the files folder location in a Drupal site from /files to
I am attempting to write some jQuery code that will expand a paragraph when
I am attempting to hide this checkbox, which is a check all checkbox in

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.