📜  HTML | DOM 源类型属性

📅  最后修改于: 2021-11-03 06:23:23             🧑  作者: Mango

HTML DOM 中的 Source type 属性用于设置或返回 元素中 type 属性的值。 type 属性用于指定媒体资源的 MIME 类型。

句法:

  • 它返回 Source 类型属性。
    sourceObject.type
  • 它用于设置 Source 类型属性。
    sourceObject.type = MIME_type 

属性值:它包含指定媒体资源的 MIME_type 的单个值MIME_type 。很少有 MIME 类型是 video/ogg、videomp4、audio/ogg 等。

返回值:它返回一个字符串值,表示媒体资源的 MIME_type。

示例 1:此示例返回 Source 类型属性。



  

    
  

  

    

GeeksforGeeks

    

HTML DOM Source type property

               

Click the button to get the type of the audio file.

               

                                  

输出:
点击按钮前:

点击按钮后:


示例 2:
此示例设置 Source 类型属性。



  

    
  

  

    

GeeksforGeeks

    

HTML DOM Source type property

               

Click the button to set the source           type of the audio file.

               

                                  

输出:
点击按钮前:

点击按钮后:

支持的浏览器:

  • 谷歌浏览器
  • 火狐
  • IE浏览器
  • 歌剧
  • 苹果浏览器