天天看点

HTML5 <embed> 标签是不是个鸡肋?

<embed> 标签定义嵌入的内容,比如插件。

<embed> 标签是 HTML 5 中的新标签。

new : HTML5 中的新属性。

属性

描述

<a target="_blank" href="http://www.w3school.com.cn/html5/att_embed_height.asp">height</a>

pixels

设置嵌入内容的高度。

<a target="_blank" href="http://www.w3school.com.cn/html5/att_embed_src.asp">src</a>

url

嵌入内容的 URL。

<a target="_blank" href="http://www.w3school.com.cn/html5/att_embed_type.asp">type</a>

type

定义嵌入内容的类型。

<a target="_blank" href="http://www.w3school.com.cn/html5/att_embed_width.asp">width</a>

设置嵌入内容的宽度。

为什么说它是个鸡肋呢?

那是因为src属性的值必须指定实际的文件扩展名,比如你想用它来播放mp3文件,

那url中的文件扩展名就必须是mp3,如果你想通过一个动态网页

比如“getMp3.php?id=12321”,它是根本播放不了的,

即使你指定了type属性为“audio/mpeg3”,它也不能将其识别为一个mp3文件。