Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีเพิ่มเพลงพื้นหลัง (Background Music) ใน HTML

แท็ก <bgsound> ใช้เล่นเพลงพื้นหลัง แต่ รองรับเฉพาะ Internet Explorer และ deprecated แล้ว

ตัวอย่าง (IE only):

<!DOCTYPE html>
<html>
  <head>
    <title>HTML bgsound Tag</title>
  </head>
  <body>
    <bgsound src="/html/yourfile.mdi"/>
    <p>Plays sound file in the background.</p>
  </body>
</html>

แอตทริบิวต์ที่รองรับ:

AttributeValueDescription
loopnumberจำนวนครั้งที่เล่นซ้ำ
srcURLพาธของไฟล์เสียง

แนะนำ: ใช้ <audio> tag แทน ซึ่งรองรับทุกเบราว์เซอร์สมัยใหม่