html5 - Commenting out HTML code on mobile devices -


this first question on stack overflow - please gentle. ;)

i working on html5 website , have decided implement html5 video @ top of home page. i've got video working fine, html code relies on "autoplay" being enabled on video - "no go" on ios (and, assume, other mobile devices):

<div class="bg1">   <div id="overlay"></div>     <video autoplay loop class="fillwidth">     <source src="video/filename.mp4" type="video/mp4"/>     <source src="video/filename.ogg" type="video/ogg"/>     <source src="video/filename.webm" type="video/webm"/>     <img src="/images/bg1.jpg" title="your browser not support <video> tag" />     </video> </div> 

notes:
1) "overlay" div contains transparent png sits above video (with transparent areas video shows through).
2) "fillwidth" class stretches video fit width of browser.
3) have image fallback older browsers, has been tested , works great.

so here's problem: when pull test site on iphone/ipad, video window shows "play" icon has slash through (since ios doesn't autoplay functionality i've set video).

so i'd know is: there way "comment out" these 6 lines of code (perhaps using javascript?) when website being viewed on mobile device, leave in desktop users?

edit:
video in background of div, user controls hidden intentionally. also: not great @ writing custom javascript, need things spelled out me if know js workaround. (sorry that.)

how ?

<div class="bg1" id="videos">   <div id="overlay"></div> </div>  <script type="text/javascript"> var ismobile = navigator.useragent.match(/(iphone|ipod|ipad|android|blackberry)/g); var videos = document.getelementbyid('videos');  if(!ismobile) {     // user-agent not iphone, ipod, ipad, android or blackberry     videos.innerhtml += '<video autoplay loop class="fillwidth">' +     '<source src="video/videonamehere.mp4" type="video/mp4"/>' +     '<source src="video/videonamehere.ogg" type="video/ogg"/>' +     '<source src="video/videonamehere.webm" type="video/webm"/>' +     '</video>'; } else {     videos.innerhtml += '<img src="/images/fallback.jpg" title="your browser not support <video> tag">'; } </script> 

here jsfiddle demo

welcome stackoverflow :~)


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -