javascript ask by attempting to do
<p>Why does this cause an 'Aw, Snap!' Error (like a plugin failed, showing a file with a face that has its eyes crossed out)?</p>

<pre><code>var vid;
var youtube;
var youtube1='&lt;object style="margin:5px;height:175px; width:235px"&gt;&lt;param name="movie" value="';
var youtube2='"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowScriptAccess" value="always"&gt;&lt;embed src="';
var youtube3='" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" height="175" width="235"&gt;&lt;/object&gt;';



if(vid=vid.replace('http://www.youtube.com/watch?v=','')){
    vid=vid.slice(0,11);
    vid='http://www.youtube.com/v/'+vid+'?version=3&amp;feature=player_detailpage&amp;autohide=1';
}else{}
youtube=youtube1+vid+youtube2+vid+youtube3;
$('#TV').html(youtube);
</code></pre>

<p>it used to work when my code was like so:</p>

<pre><code>if(youtube.search('http://www.youtube.com/v/')== -1){
    vid=vid.replace('http://www.youtube.com/watch?v=','');
    vid='http://www.youtube.com/v/'+vid+'?version=3&amp;feature=player_detailpage&amp;autohide=1';
    }else{}
</code></pre>

<p>I would have thought that asking if js can do something whilt attempting it would work and be faster!? I'm sure I've seen this done in php.</p>

<p>Is something like this possible?</p>
