gpt4 book ai didi

javascript - 检测和编辑MP3链接

转载 作者:行者123 更新时间:2023-12-03 01:00:52 25 4
gpt4 key购买 nike

我需要使用JavaScript检测页面内的MP3链接,并将文本替换为:

<embed type="application/x-shockwave-flash"
src="http://www.google.com/reader/ui/3247397568-audio-player.swf?
audioUrl=http://LINK" width="400" height="27"
allowscriptaccess="never" quality="best" bgcolor="#ffffff"
wmode="window" flashvars="playerMode=embedded" />

MP3的URL值?

我该怎么办?

最佳答案

[].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" />

关于javascript - 检测和编辑MP3链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8537224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com