美文网首页
H5的embed标签和对象的使用

H5的embed标签和对象的使用

作者: 最帅的坏兔子 | 来源:发表于2018-11-28 19:54 被阅读10次
<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
   <title>pdfEmbed使用</title>
</head>
<body>
   <div id="test">
       <embed width="600" height="880" type="application/pdf" src="ECMAScript 6入门.pdf"></embed>
   </div>
   <script>
       function pdfEmbed(){
           var pdfEmbed = document.createElement('EMBED'); //创建embed对象
           pdfEmbed.setAttribute('src','ECMAScript 6入门.pdf');  //设置src属性
           pdfEmbed.setAttribute('type','application/pdf');    //设置type属性
           pdfEmbed.setAttribute('width','600');   //设置width属性
           pdfEmbed.setAttribute('height','880');  //设置height属性
           document.getElementById('test').appendChild(pdfEmbed);  //添加节点
       }
       //函数调用
       (function(){
           pdfEmbed();
       })();
   </script>
</body>
</html>
浏览器效果pdfEmbed.png

左边的PDF是H5embed标签的使用方法,右边是embed对象的使用方法。

相关文章

网友评论

      本文标题:H5的embed标签和对象的使用

      本文链接:https://www.haomeiwen.com/subject/skizqqtx.html