Solved

DHTML YouTube movie

Posted on 2006-11-28
2
634 Views
Last Modified: 2012-05-05
I'm trying to come up w/ a JavaScript version of the YouTube movie snippet.  My goal is to be able to pass a js function a YouTube id and have the appropriate movie play w/o the page refreshing. For example I'd like to be able to click on one of the links below, and have the DIV's contents load the selected movie.

<A HREF="javascript:showMovie('li5-f7GpYSU');>Show MST3K 1/10</A>
<A HREF="javascript:showMovie('oONMPeqJFYA');>Show MST3K 2/10</A>

<div id="movie_container">No movie selected</div>



for reference, here is the raw YouTube HTML:

<object width="425" height="350">
      <param name="movie" value="http://www.youtube.com/v/li5-f7GpYSU"></param>
      <param name="wmode" value="transparent"></param>
      <embed src="http://www.youtube.com/v/li5-f7GpYSU" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">
      </embed>
</object>


Thanks!
Zumpoof
0
Comment
Question by:zumpoof
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
enachemc earned 500 total points
ID: 18026145
you can use document.getElementById("movie_container").innerHTML='<object width="425" height="350">     <param name="movie" value="http://www.youtube.com/v/li5-f7GpYSU"></param>     <param name="wmode" value="transparent"></param>     <embed src="http://www.youtube.com/v/li5-f7GpYSU" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">     </embed></object>';
//one line above

Or you can dinamicaly create the object and assign the required properties, and then attach this new object as a child of the movie_container object.
0
 
LVL 12

Expert Comment

by:enachemc
ID: 18026167
var obj = document.createElement("object");
obj.width=425;
obj.height=425;
var param = document.createElement("param");
param.name = "movie"
......
obj.insertBefore(param);//this will add the param element to the object element
....
document.getElementById.insertBefore(obj);


0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question