doudeng1870 2017-11-23 19:34
浏览 43

检测浏览器宽度并防止下载页面段

I intend to use html5 video header for my web page. I'm using Codeignitor(PHP) on the server and bootstrap and jquery on client side. video header is nice and effective on larger screens sizes. but it takes a considerable time to load on mobile browsers on lower download speeds. so that I want to prevent following code portion from downloading or executing (not to hide the downloaded elements) on mobile browsers. for the performances sake 1. can i detect user browser width and type(mobile or not) on the server? 2. Can i analyse the http request to detect that? 3. Can i do this without Ajax and page Redirectings?

    <div class="container-fluid">
    <div class="row">
       <div class="header-container">
      <div class="video-container">
        <video id="video" autobuffer  preload="true" autoplay="autoplaymuted" loop="loop" volume="0" poster="pic.jpg">
          <source src="video/cover.mp4">
          <source src="video/cover.webm" type="video/webm">
          <source src="video/cover.ogv" type="video/ogg">   
        </video>
      </div>
      <h3> my web video header </h3>
    </div>
    </div> 
  • 写回答

1条回答 默认 最新

  • duanmao1319 2019-04-06 01:25
    关注

    Please try this. May be it will work for you.

    $(document).ready(function(e) {
        var getWidth = $(window).width();
        console.log( 'Onload' + getWidth );
    });
    window.onresize = function() {
        var getWidth = $(window).width();
        console.log( 'on resize window' + getWidth );
    };
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置