首页 > Web开发 > 详细

html 标签前插入视频标签,并修改属性

时间:2014-11-26 02:19:41      阅读:315      评论:0      收藏:0      [点我收藏+]

<article>文章</article>

?

<script type="text/javascript">

<!--

function videodivscript(){

//获得标签<article>

? ? var articletag =document.getElementsByTagName("article");

? ? if(articletag.length>0){

//创建标签div

? ? ? ? var videodivElement= document.createElement("div");

//修改属性

? ? ? ? videodivElement.setAttribute("class","video_container");

//创建视频标签

? ? ? ? var videoElement= document.createElement("video");

? ? ? ? videoElement.setAttribute("src","http://flv1.gmw.cn/gmw/videoroot/2014-11-24/1416794580498.mp4");

? ? ? ? videoElement.setAttribute("type","video/mp4");

? ? ? ? videoElement.setAttribute("controls","");

? ? ? ? videoElement.setAttribute("poster","http://flv1.gmw.cn/gmw/videoroot/2014-11-24/1416794580498.jpg");

? ? ? ? videoElement.setAttribute("preload","none");

//新标签相互嵌套

? ? ? ? videodivElement.appendChild(videoElement);

//在标签article之前插入标签videodivElement

? ? ? ? document.body.insertBefore(videodivElement , articletag[0] );

? ? }

}

//运行

videodivscript();

-->

</script>

html 标签前插入视频标签,并修改属性

原文:http://worktianqi.iteye.com/blog/2160013

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!