Back To Resources, Guides and Information

Disabling The Link On YouTube's Embedded Video Player

This was posted on 02/03/2011 and was filed in Tips And Tricks | (6 Comments)

Sometimes you might want to prevent your users from clicking through a YouTube video away from your site. This code snippet will stop that from happening. It's a quick and easy addition to the embed code that you pull from YouTube itself.

Place this before the <embed tag starts:

<param name="allowNetworking" value="internal"></param>

Place this inside of the <embed tag:

allowNetworking="internal"

Without This Code:

<object width="480" height="385">
<param name="movie" value="http://www.youtube.com/v/twYpsdCqRm8?fs=1&amp;hl=en_US"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/twYpsdCqRm8?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
</object>

With This Code:

You'll notice that with this code, clicking on the video while playing does not take the user away from your site and over to YouTube.

<object width="480" height="385">
<param name="movie" value="http://www.youtube.com/v/twYpsdCqRm8?fs=1&amp;hl=en_US"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<param name="allowNetworking" value="internal"></param>
<embed src="http://www.youtube.com/v/twYpsdCqRm8?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385" allowNetworking="internal"></embed>
</object>

You'll notice that when we use this code, you can't click on the video to get over to YouTube. It's a nice quick and easy feature to add to your site to prevent your users from accidentally clicking away.

Update: This No Longer Works!

Looks like YouTube has changed the way their player works. I will update this if and when I find a new fix.

Have I Helped You? Share Some Love!

Comments

Showing All Comments

smith on 03/08/2012:

unfortunately this code is not working for me!As mine editor changes allowNetworking="internal" to allownetworking="internal" makes the capital N into small.

on 02/14/2012:

Hey doc - looks like they've removed the ability to make this happen with their player. I'll update this post if and when I find another workaround. Let me know if you find something!

doc on 02/14/2012:

for me, the youtube video opened a new tab. Perhaps since you wrote this, YouTube has changed their code to prevent <param name="allowNetworking" value="internal" />

maxisawesome on 07/10/2011:

You are very welcome!

Priyank Ahuja on 07/09/2011:

Thanks a lot dear it was really very helpful.!!

Sunny on 02/16/2011:

Thanks a lot, this was very helpful!

Comment On This

© Max Morgan Design 2009 - 2012 | Page Generated In 0.17458 Seconds Using 42 MYSQL Queries