网页添加音乐方法
每当网页刷新及打开一次随机播放一首BGM内容十首音乐,网易云、酷狗音乐外链,可以自定义更换 可以从这里进行获取自己的音乐外链 音乐以下内容添加载标签前就可以了
音乐代码
<!--5随机背景音乐开始--> <!--音乐内容可自行换-->
<div id="luyumusic"> </div> <script>//还是要分开 var m1 = "http://fs.pc.kugou.com/202009131950/1d645834a0eab1e796f26c9bdd574c18/G231/M06/00/17/Jw4DAF9MabmIQegcAAtJ97FDY1QAAAjigPARswAC0oP166.mp3"; //不是因为寂寞才想你 var m2 = "http://fs.pc.kugou.com/202009131952/5ab17e603c6b0849f7cd2d19e4f15a38/G187/M0A/02/11/W4cBAF3zmdGASfhpAHetlns32CY546.mp3"; //七秒钟的记忆 var m3 = "http://m7.music.126.net/20200913202022/e9647f3d3fa8cbae102779d146d60849/ymusic/5608/070b/0e52/ab50cc08820a0466700298bc61047eb9.mp3"; //黄梅戏 (抖音DJ版)抖音热歌DJ var m4 = "http://m7.music.126.net/20200913202102/69e6651d34be2440ef85ac22df53df0f/ymusic/0652/5208/0553/188e33eab5eb7cf16e95297f62100e15.mp3"; //你是人间四月天 var m5 = "http://m8.music.126.net/20200913210602/d62c9137f921c66f491eae891b33529c/ymusic/5152/5552/030c/f860fa842eb8201274264f2d9eda6139.mp3"; //爸爸妈妈 var m6 = "http://m8.music.126.net/20200913210655/803e0fc5914faf5209101173289a3552/ymusic/78e7/1070/78e8/08e435a238de98cbdab01c6cd32f2743.mp3"; //夏天的风 var m7 = "http://m701.music.126.net/20200913210749/8dd4c571522b8f2e07b7d563a2f230b3/jdymusic/obj/w5zDlMODwrDDiGjCn8Ky/2180586519/98b2/4d51/b6d3/c8c65de6a0bf053a2cd94d1f9473d069.mp3"; // 收敛 var m8 = "http://m701.music.126.net/20200913210907/a8b47a8667f4652108b9d2e1fd0fe483/jdymusic/obj/w5zDlMODwrDDiGjCn8Ky/1982156329/01cb/e133/624f/d2778cef75e3bcadaf389b573ad39170.mp3"; //所念皆星河 var m9 = "http://m7.music.126.net/20200913203025/c125757b55c8c51cd292aac6d421a844/ymusic/020c/5652/075e/5fcded78c7a8df3f91e404ddbdaf226b.mp3"; //你走后1.0 var m10 = "http://m8.music.126.net/20200913211210/464f9206535c7452e200f5a12e82730b/ymusic/015c/0658/000e/664f4e822612bec1739b7d2803cb5f1d.mp3"; var x = Math.round(Math.random() * 9); console.log(x); if (x == 0) x = m1 else if (x == 1) x = m2 else if (x == 2) x = m3 else if (x == 3) x = m4 else if (x == 4) x = m5 else if (x == 5) x = m6 else if (x == 6) x = m7 else if (x == 7) x = m8 else if (x == 8) x = m9 else x = m10 var obj = document.getElementById("luyumusic"); obj.innerHTML = "<audio src=" + """ + x + """ + " " + "height="0"" + "autoplay="true"" + "loop="true"" + ">" + "</audio>";</script>
<!--5随机背景音乐结束 -->
请登录后发表评论
注册
请登录后查看评论内容