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.