[].map.call(document.links, function(v){
if(v.href.indexOf(".mp3") === v.href.length - 4) {
return '<embed type="application/x-shockwave-flash" ' +
'src="http://www.google.com/reader/ui/3247397568-audio-player.swf?' +
'audioUrl='+encodeURIComponent(v.href)+' width="400" height="27" ' +
'allowscriptaccess="never" quality="best" bgcolor="#ffffff" ' +
'wmode="window" flashvars="playerMode=embedded" />';
}
return "";
}).join("");
http://jsfiddle.net/e5DSU/2/
頁面上的以下鏈接:
<a href="/asd/asd/asd.mp3"></a>
<a href="/asd/asd/asd.mp3"></a>
<a href="/asd/asd/asd.mp3"></a>
得出:
<embed type="application/x-shockwave-flash" src="http://www.google.com/reader/ui/3247397568-audio-player.swf?audioUrl=http%3A%2F%2Ffiddle.jshell.net%2Fasd%2Fasd%2Fasd.mp3 width="400" height="27" allowscriptaccess="never" quality="best" bgcolor="#ffffff" wmode="window" flashvars="playerMode=embedded" />
<embed type="application/x-shockwave-flash" src="http://www.google.com/reader/ui/3247397568-audio-player.swf?audioUrl=http%3A%2F%2Ffiddle.jshell.net%2Fasd%2Fasd%2Fasd.mp3 width="400" height="27" allowscriptaccess="never" quality="best" bgcolor="#ffffff" wmode="window" flashvars="playerMode=embedded" />
<embed type="application/x-shockwave-flash" src="http://www.google.com/reader/ui/3247397568-audio-player.swf?audioUrl=http%3A%2F%2Ffiddle.jshell.net%2Fasd%2Fasd%2Fasd.mp3 width="400" height="27" allowscriptaccess="never" quality="best" bgcolor="#ffffff" wmode="window" flashvars="playerMode=embedded" />
感謝您的分享。問題是什麼? – Dutchie432 2011-12-16 16:38:47