Solved

Play youtube video in new window

Posted on 2010-11-17
7
1,486 Views
Last Modified: 2012-05-10
How can I play a youtube in a new window from the embedded code of youtube? Is this possible so it will play once the user clicks on the youtube embedded tag?

Thank you,
Victor
0
Comment
Question by:Victor Kimura
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 6

Expert Comment

by:Kris Montgomery
ID: 34153284
I think you are asking how to put the YouTube video on another site, correct?

That would just be copying the embed code and pasting it in the HTML code of your webpage.

The entire video will display on your page.

Thanks!

mug
0
 
LVL 6

Expert Comment

by:Codebot
ID: 34153630
0
 

Author Comment

by:Victor Kimura
ID: 34154732
Thank you for the links and the suggestion. But what I'd like is to have users click on the youtube link so that a new window (I guess a javascript window) to open so the video will play automatically in the new window. I think I saw a thread regarding this using javascript but I couldn't find the code for it. Any ideas?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 2

Assisted Solution

by:Schells_Web_Design
Schells_Web_Design earned 333 total points
ID: 34156739
I'm not quite sure I understand all you are asking, but you can just use a simple target statement in a link if the link is from your website to the youtube.com website.

<a href="youtube.com link" target="new">Link goes here</a>

Are you talking about taking the youtube video and putting it on YOUR site and then linking to that video from your own site?

If so, then I would just create a separate page with the video code on it and use the same link above, but it would just go to your own site instead the youtube.com site.

Or you can javascript the size of the pop up if the new page just has the video on it:

<a href="javascript:void(0)"onclick="window.open('video link','linkname','height=380, width=300,scrollbars=no')">Link goes here</a>

I don't think there's an easy way to embed the youtube code on your site and add a new window tag.  You would have to create a hidden <div> area to store the code and then create a javascript to call the <div> into a new pop-up window. Once that's done ... you will need a <a href> to call the script to open the window to play the hidden embed <div>.

Much easier to just to plop the code from youtube onto a page and open a new window to the dimentions of the video.

Hope that helps.
0
 

Author Comment

by:Victor Kimura
ID: 34157681
Hi Schells_Web_Design,

I think if the javascript code that you suggested is good but I'd like the youtube to play automatically once that javascript window opens. You mention to use <a href> to call the script to open the window to play the hidden embed. Is this referring to playing the youtube once it's opened?
0
 
LVL 2

Accepted Solution

by:
Schells_Web_Design earned 333 total points
ID: 34157765
Playing automatically is something you would put into the embed tag.  Once you see the URL for the video, just add this code right behind it (no spaces):    &autoplay=1

So if the link is this:   http://www.youtube.com/v/video1
The autoplay link is this:    http://www.youtube.com/v/video1&autoplay=1

As far as the javascript I mentioned at the end - it would open a web page you create with the embedded youtube on it. Just copy & paste the youtube code onto a page.

Does that help?
0
 
LVL 6

Assisted Solution

by:Codebot
Codebot earned 167 total points
ID: 34164461
use this
<object width="640" height="385"><param   name="movie" value="http://www.youtube.com/v/QDe6MZQjpho?fs=1&amp;hl=en_GB"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"autoplay="1"></param><embed src="http://www.youtube.com/v/QDe6MZQjpho?fs=1&amp;hl=en_GB;autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" autoplay="1" width="640" height="385"></embed></object>

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

832 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