Forum Moderators: open
this is what I have right now:
<a href="#" onclick="flashplayer_loadAndPlay('my-mp3-file.mp3');"> My links load mp3 files into a flash player. I want to make them work also for no-flash users (like iPhone). I tried to put a link to an mp3 file into href, but this breaks the whole functionality for flash browsers (it just opens a link).
Your link would look like this:
<a href="my-mp3-file.mp3" onclick="return flashplayer_loadAndPlay('my-mp3-file.mp3');">
Then change your flashplayer_loadAndPlay function to do something like this:
function flashplayer_loadAndPlay(fileToPlay) {
if (!swfobject.hasFlashPlayerVersion("6.0.0"))
return true;
}
// Do your thing to play file in flash here...
return false;
}
Obviously, you'd need to include the swfobject code [code.google.com] for this example to work. What this does is if it doesn't detect Flash (my example checks for version 6.0.0 or greater), then the function will return true, which will cause the link to follow the href value. Otherwise, it will play the file in the Flash player and return false, causing the href value to be ignored.
Hope that helps.