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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:22:31+00:00 2026-06-06T09:22:31+00:00

I have jQuery on my site. I also have a youtube video using a

  • 0

I have jQuery on my site. I also have a youtube video using a standard object/embed code. How would I use jQuery so that when the youtube video finishes playing, the page is redirected to a new page?

** EDIT *

This is my youtube embed:

<div id="embed_player">
    <object id="embed_object" type="application/x-shockwave-flash" width="640" height="385" data="http://www.youtube.com/v/LgJxPKfV8sw">
        <param name="movie" value="http://www.youtube.com/v/LgJxPKfV8sw">
        <param name="allowfullscreen" value="true">
        <param name="allowscriptaccess" value="true">
        <param name="wmode" value="transparent">
        <param name="flashvars" value="autoplay=0&hd=1&fs=1&rel=0&version=3&enablejsapi=1&playerapiid=ytplayer">
    </object>
</div>

I have tried adding the following javascript to my page, but with no success…

<script type="text/javascript" src="http://www.youtube.com/player_api"></script>
<script type="text/javascript">
function onYouTubePlayerReady(playerId) {
  ytplayer = document.getElementById("ytplayer");
  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {
   alert("Player's new state: " + newState);
}
</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-06T09:22:32+00:00Added an answer on June 6, 2026 at 9:22 am

    You need to bind to the onstatechange event:

    onStateChange
    This event is fired whenever the player’s state changes. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5). When the SWF is first loaded it will broadcast an unstarted (-1) event. When the video is cued and ready to play it will broadcast a video cued event (5).

    Some good documentation here: https://developers.google.com/youtube/js_api_reference#Adding_event_listener

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

Sidebar

Related Questions

I have website that use XMLHttpRequest (jQuery, actually). I also have another site running
I have a script on jquery that load some site in iframe using: $(#demo_frame).attr('src',
We have a site that we would like our customers to embed in their
I have added JQUERY Galleria a site that I have created but am having
I have a mobile site running with jQuery Mobile. I want to have standard
I am developing a site for mob using jquery mobile. I have a content
I have a multi-languages Jquery Mobile site (Backend is Coldfusion8/MySQL). I'm using a generic
I just made my first jQuery mobile site. I want to have people that
I usually have jQuery code that is page specific along with a handful of
i have a site using jquery lazyload its working fine, but now i want

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.