要完成此效果需要两个步骤
第一步:把如下代码加入到区域中
<script LANGUAGE="JavaScript">
counter = 0;
html = true;
mp3list = "#EXTM3U";
if(html) {
mp3list += "
";
}
mp3list += "\n";
file = "";
songs = new Array();
function addsong() {
file = document.forms[0].file.value;
file = file.toLowerCase();
if(file == "") {
alert("按“浏览”选择一个文件");
}
else {
fn = file;
char = unescape("%5C");
while(fn.indexOf(char) != -1) {
pos = fn.indexOf(char);
fn = fn.substring(pos + 1, fn.length);
}
if(fn.indexOf('.mp3') == -1) {
alert("只能是MP3格式文件!");
}
else {
songs[counter] = file;
document.forms[0].sofar[counter] = new Option((counter+1) + ": " + fn, file, false, true);
counter++;
}
document.forms[0].file.value = "";
}
}
function finish() {
if(counter == 0) {
alert("请加入曲目到列表中!");
}
else {
mp3l = songs.length;
for(i = 0; i < mp3l; i++) {
if(songs[i] != "") {
mp3list += songs[i];
if(html) {
mp3list += "
"
}
mp3list += "\n"
}
}
document.write(mp3list);
if(html) {
document.write("
");
document.write("alert('创建一外空白文件,拷贝以下代码到文件中并保存为.m3u后缀的文件\\n\\n按浏览器返回按钮,回到编辑页面')");
document.write("");
}
}
document.forms[0].sofar.blur();
}
function deletethis() {
if(counter > 0) {
counter--;
document.forms[0].sofar[counter] = null;
songs[counter] = "";
}
else {
alert("列表中无项目!");
}
}
</script>
第二步:把如下代码加入到区域中
选择MP3文件后按添加按钮,全部选择完毕后按“结束”。