Here is my HTML:
<a class="video iframe" href="http://www.youtube.com/watch?v=Psk2Pq03rv0&#38;fs=1">Arbitrary text</a>
Here is the Fancybox javascript:
<script type='text/javascript'>
$(document).ready(function(){
$("a.video").fancybox({
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode': 'transparent',
'allowfullscreen': 'true'
}
});
return false;
});
Firebug Console says:
this.href is undefined
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
As a result, clicking this link takes the user to YouTube and does not trigger Fancybox.
Changing the problematic line to 'href' : this.href.replace(new RegExp("watch?v=", "i"), 'v/'),
which seems more correct to me, yields the same result.
Any advice?
EDIT: I adjusted my script to only include the parts relevant to my question.