title: Extract Youtube video id from URL parameter?
body: <p>For example if the youtube video is <code>http://www.youtube.com/watch?v=6hTPDG0fGCU</code> and my website is <code>http://mysite.com?youtubeurl=http://www.youtube.com/watch?v=6hTPDG0fGCU</code> then set the id in this case <code>6hTPDG0fGCU</code> as <code>var youtubevideoid</code>
  something i have working atm but only for replacing an iframe src.</p>
  
  <pre><code>&lt;script type="text/javascript" &gt;
  $(document).ready(main);
  
  function main()
  {
   $('iframe').attr('src', getIframeUrl() );
   registerEvents();
   resizeIframe();
  }
  
  function getIframeUrl()
  {
   var url = window.location.href;
   var iframe_url = 'http://lowkeyunofficial.blogspot.com/';
   var param_start = url.indexOf("iframe=");
   if( param_start != -1 )
    iframe_url = url.substr(param_start+7,url.length-param_start-7);
   if( iframe_url.indexOf("http://") == -1)
    iframe_url = "http://" + iframe_url ;
  
   return iframe_url;
  }
  &lt;/script&gt;
  </code></pre>