var obox = document.getelementbyid('box'); var ocover = document.queryselector('#box .cover'); var odt = document.queryselector('#box .cover dt'); var ovideo = document.queryselector('#box video'); var close = document.queryselector('#box a'); var bool = true; close.onclick = function(ev){ ev.stoppropagation(); obox.style.display = 'none'; } obox.onclick = function(){ if (bool){ ocover.style.visibility = 'hidden'; odt.style.opacity = 0; ovideo.play(); bool = false; }else{ ocover.style.visibility = 'visible'; odt.style.opacity = 1; ovideo.pause(); bool = true; } } var browser={ versions:function(){ var u = navigator.useragent, app = navigator.appversion; return {//移动终端浏览器版本信息 trident: u.indexof('trident') > -1, //ie内核 presto: u.indexof('presto') > -1, //opera内核 webkit: u.indexof('applewebkit') > -1, //苹果、谷歌内核 gecko: u.indexof('gecko') > -1 && u.indexof('khtml') == -1, //火狐内核 mobile: !!u.match(/applewebkit.*mobile.*/), //是否为移动终端 ios: !!u.match(/\(i[^;]+;( u;)? cpu.+mac os x/), //ios终端 android: u.indexof('android') > -1 || u.indexof('linux') > -1, //android终端或者uc浏览器 iphone: u.indexof('iphone') > -1 , //是否为iphone或者qqhd浏览器 ipad: u.indexof('ipad') > -1, //是否ipad webapp: u.indexof('safari') == -1, //是否web应该程序,没有头部与底部 weixin: u.indexof('micromessenger') > -1, //是否微信 qq: u.match(/\sqq/i) == " qq" //是否qq }; }(), language:(navigator.browserlanguage || navigator.language).tolowercase() } $(document).ready(function(){ $('#vid_mask').bind('click', function() { $('#vid')[0].play(); }); $('#vid')[0].click(); $('#vid')[0].play(); }); if(browser.versions.mobile || browser.versions.ios || browser.versions.android || browser.versions.iphone || browser.versions.ipad){ var v=document.getelementbyid('vid'); var s=document.getelementbyid('yx'); var aut=v.getattributenode('autoplay'); v.removeattributenode(aut); var auts=s.getattributenode('autoplay'); s.removeattributenode(auts); }else{ var auto=document.createattribute('autoplay'); auto.nodevalue="true"; v.setattributenode(auto); s.setattributenode(auto); }