Created
September 19, 2011 17:45
-
-
Save chrismeller/1227055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Video Test</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready( function () { | |
// hook the click event for any A links with a rel that starts with 'youtube' | |
$('a[rel^="youtube"]').click( function ( ) { | |
// what is the rel? | |
var rel = $(this).attr('rel'); | |
// trim off the leading 'youtube' | |
rel = rel.replace( 'youtube', '' ); | |
// now replace the brackets | |
rel = rel.replace( '[', '' ).replace( ']', '' ); | |
var attributes = rel.split(','); | |
alert( 'width: ' + attributes[0] + ', height: ' + attributes[1] + ', id: ' + attributes[2] ); | |
// be sure to return false so the browser doesn't continue to whatever the href is | |
return false; | |
} ); | |
} ); | |
</script> | |
</head> | |
<body> | |
<a href="#" rel="youtube[322,300,abcd]">One</a> | |
<a href="#" rel="youtube[322,300,efgh]">Two</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment