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++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?