想装修自己的淘宝店铺,但是不会免费放背景音乐,现在的音乐代码还有哪些可以用的呢(音乐总是那么迷人,店铺中如果加入适当的背景音乐,往往会让顾客轻松舒畅)
加背景音乐,其实就是贴段儿代码。
咱们从最简单的开始。最简洁的代码是这样的:
<bgsound src='/files/touch/images/load.gif' data-src="你的背景音乐地址" loop=-1>
或者:
<embed autostart="true" loop="-1" controls="ControlPanel" width="0" height="0" src='/files/touch/images/load.gif' data-src="你的背景音乐地址">
两者的最大区别在于前者页面被最小化之后音乐就停了;后者页面最小化后音乐还是照旧播放,直到窗口被关闭。
共同点是,页面是当前窗口的时候,按ESC键,音乐都会停。
以上两段代码都是放在<head>之间的
再来,稍微复杂一些的:有淘友问,能不能让背景音乐每次刷新都变不同的曲目,这个也不难。
把如下代码加入<body>区域中,页面打开时就会有随机播放背景音乐
<SCRIPT language="java - script">
<!--
var sound1="song1.mid"
var sound2="song2.mid"
var sound3="song3.mid"
var sound4="song4.mid"
var sound5="song5.mid"
var sound6="song6.mid"
var sound7="song7.mid"
var sound8="song8.mid"
var sound9="song9.mid"
var sound10="song10.mid"
var x=Math.round(Math.random()*9)
if (x==0) x=sound1
else if (x==1) x=sound2
else if (x==2) x=sound3
else if (x==3) x=sound4
else if (x==4) x=sound5
else if (x==5) x=sound6
else if (x==6) x=sound7
else if (x==7) x=sound8
else if (x==8 ) x=sound9
else x=sound10
if (navigator.appName=="Microsoft Internet Explorer" )
document.write('<bgsound src='/files/touch/images/load.gif' data-src='+'"'+x+'"'+' loop="infinite">')
else
document.write('<embed src='/files/touch/images/load.gif' data-src='+'"'+x+'"'+'hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')
//-->
</SCRIPT>
把你找来的音乐分别替换上面"songN.mid"部分,然后把这短代码贴在<head>之间就好了。