Need switcher between iOS and Android devices


#1

This code works for displaying a video on iOS devices, but not in Android:

<a href="#" onclick="window.open('http://www.youtube.com/watch?v=nxP0wgBf6Zk', '_blank');">

This code works for Android:

<a href="http://www.youtube.com/watch?v=NRJHKzU_t1M">

I need to code each video so it will switch between the two based on device detection. Something like this:

<script>
if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || (navigator.userAgent.match(/iPad/i)) {
// use <a href="#" onclick="window.open('http://www.youtube.com/watch?v=NRJHKzU_t1M', '_blank');">
}
else {
// use <a href="http://www.youtube.com/watch?v=NRJHKzU_t1M">
}
</script>

The full html context for the video looks like:

	<ul class="pageitemvid">
		<li class="menu"><font color='"#FF0000"'><a href="http://www.youtube.com/watch?v=NRJHKzU_t1M"></font>
			<span class="name">A mighty Fortress is our God</span>
        	<span class="detailbutton"></span></a>
    	</li>
    </ul>

It's clear I'll need to hand-code each video instance to incorporate this device detection. My mind is awfully fuzzy at this point. How do I work this in?


#2