澳门皇冠金沙网站-澳门皇冠844网站

热门关键词: 澳门皇冠金沙网站,澳门皇冠844网站

常用小功能皇冠投注app,前端相关数据监控

前者相关数据监控

2015/08/16 · HTML5 · 数量监察和控制

原稿出处: AlloyTeam   

类型开辟到位外发后,未有三个监督检查种类,咱们很难理解到公布出去的代码在用户机器上进行是还是不是准确,所以要求树立前端代码质量相关的监督系统。

就此大家供给做以下的风流洒脱对模块:

豆蔻梢头、采摘脚本实践错误

JavaScript

function error(msg,url,line){ var REPORT_U奥德赛L = "xxxx/cgi"; // 采摘报告数据的新闻 var m =[msg, url, line, navigator.userAgent, new Date];// 搜聚错误音信,产生错误的本子文件互连网地址,用户代理信息,时间 var url = REPORT_ULX570L m.join('||');// 组装错误报告音信内容U景逸SUVL var img = new Image; img.onload = img.onerror = function(){ img = null; }; img.src = url;// 发送数据到后台cgi } // 监听错误反馈 window.onerror = function(msg,url,line){ error(msg,url,line); }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function error(msg,url,line){
   var REPORT_URL = "xxxx/cgi"; // 收集上报数据的信息
   var m =[msg, url, line, navigator.userAgent, new Date];// 收集错误信息,发生错误的脚本文件网络地址,用户代理信息,时间
   var url = REPORT_URL m.join('||');// 组装错误上报信息内容URL
   var img = new Image;
   img.onload = img.onerror = function(){
      img = null;
   };
   img.src = url;// 发送数据到后台cgi
}
// 监听错误上报
window.onerror = function(msg,url,line){
   error(msg,url,line);
}

因此拘禁后台系统,我们能够看看页面上每一次错误的音信,通过那些消息我们能够火速定位同期解决难题。

二、收集html5 performance信息

performance 包涵页面加载到实行到位的百分百生命周期中分化实行步骤的实行时间。performance相关小说点击如下:动用performance API 监测页面质量

计量差异步骤时间相对于navigationStart的日子差,可以透过相应后台CGI搜集。

JavaScript

function _performance(){ var REPORT_URL = "xxxx/cgi?perf="; var perf = (window.webkitPerformance ? window.webkitPerformance : window.msPerformance ), points = ['navigationStart','unloadEventStart','unloadEventEnd','redirectStart','redirectEnd','fetchStart','domainLookupStart','connectStart','requestStart','responseStart','responseEnd','domLoading','domInteractive','domContentLoadedEventEnd','domComplete','loadEventStart','loadEventEnd']; var timing = pref.timing; perf = perf ? perf : window.performance; if( perf && timing ) { var arr = []; var navigationStart = timing[points[0]]; for(var i=0,l=points.length;i<l;i ){ arr[i] = timing[points[i]] - navigationStart; } var url = REPORT_URL arr.join("-"); var img = new Image; img.onload = img.onerror = function(){ img=null; } img.src = url; }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function _performance(){
   var REPORT_URL = "xxxx/cgi?perf=";
   var perf = (window.webkitPerformance ? window.webkitPerformance : window.msPerformance ),
      points = ['navigationStart','unloadEventStart','unloadEventEnd','redirectStart','redirectEnd','fetchStart','domainLookupStart','connectStart','requestStart','responseStart','responseEnd','domLoading','domInteractive','domContentLoadedEventEnd','domComplete','loadEventStart','loadEventEnd'];
   var timing = pref.timing;
   perf = perf  ? perf : window.performance;
   if( perf  && timing ) {
      var arr = [];
      var navigationStart = timing[points[0]];
      for(var i=0,l=points.length;i<l;i ){
         arr[i] = timing[points[i]] - navigationStart;
      }
   var url = REPORT_URL arr.join("-");
   var img = new Image;
   img.onload = img.onerror = function(){
      img=null;
   }
   img.src = url;
}

经过后台接口搜聚和计算,大家能够对页面实行质量有很详细的摸底。

三、计算各种页面包车型客车JS和CSS加载时间

在JS或许CSS加载此前打上时间戳,加载之后打上时间戳,何况将数据反馈到后台。加载时间反映了页面白屏,可操作的等候时间。

XHTML

<script>var cssLoadStart = new Date</script> <link rel="stylesheet" href="xxx.css" type="text/css" media="all"> <link rel="stylesheet" href="xxx1.css" type="text/css" media="all"> <link rel="stylesheet" href="xxx2.css" type="text/css" media="all"> <sript> var cssLoadTime = ( new Date) - cssLoadStart; var jsLoadStart = new Date; </script> <script type="text/javascript" src="xx1.js"></script> <script type="text/javascript" src="xx2.js"></script> <script type="text/javascript" src="xx3.js"></script> <script> var jsLoadTime = ( new Date) - jsLoadStart; var REPORT_URL = 'xxx/cgi?data=' var img = new Image; img.onload = img.onerror = function(){ img = null; }; img.src = REPORT_URL cssLoadTime '-' jsLoadTime; </script>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script>var cssLoadStart = new Date</script>
<link rel="stylesheet" href="xxx.css" type="text/css" media="all">
<link rel="stylesheet" href="xxx1.css" type="text/css" media="all">
<link rel="stylesheet" href="xxx2.css" type="text/css" media="all">
<sript>
   var cssLoadTime = ( new Date) - cssLoadStart;
   var jsLoadStart = new Date;
</script>
<script type="text/javascript" src="xx1.js"></script>
<script type="text/javascript" src="xx2.js"></script>
<script type="text/javascript" src="xx3.js"></script>
<script>
   var jsLoadTime = ( new Date) - jsLoadStart;
   var REPORT_URL = 'xxx/cgi?data='
   var img = new Image;
   img.onload = img.onerror = function(){
      img = null;
   };
   img.src = REPORT_URL cssLoadTime '-' jsLoadTime;
</script>

XHTML

<a href="" target="_blank"> </a>

1
<a href="https://github.com/perltzhu/js-data-report" target="_blank"> </a>

1.让文字不停地滚动

参谋资料:

  • html5 performance en
  • html5 performance cn
  • javascript onerror api

    1 赞 1 收藏 评论

皇冠投注app 1

  <MA陆风X8QUEE>滚动文字</MA锐界QUEE>

2.记录并体现网页的结尾纠正时间

  <script language=Javascript>
  document.write("最终更新时间: " document.lastModified "")
  </script>

3.闭馆当前窗口

  <a href="/"onClick="javascript:window.close();return false;">关闭窗口</a>

4.5秒后关门当前页

  <script language="Javascript">
  <!--
  setTimeout('window.close();',5000);
  -->
  </script>

5.2秒后载入内定网页

  <head>
  <meta http-equiv="refresh" content="2;URL=
  </head>

6.增添到收藏夹

  <script Language="Javascript">
  function bookmarkit()
  {
  window.external.addFavorite('')
  }
  if (document.all)document.write('<a href="#" onClick="bookmarkit()">参预收藏夹</a>')
  </script>

7.让超链接不展现下划线

  <style type="text/css">
  <!-
  a:link{text-decoration:none}
  a:hover{text-decoration:none}
  a:visited{text-decoration:none}
  ->
  </style>

8.幸免鼠标右键的动作

  <script Language = "Javascript">
  function click() { if (event.button==2||event.button==3)
皇冠投注app,  {
  alert('禁止鼠标右键');
  }
  document.onmousedown=click // -->
  </script>

9.安装该页为首页

  <body bgcolor="#FFFFFF" text="#000000">
  <!-- 网址:
  <a class="chlnk" style="cursor:hand" HREF
  onClick="this.style.behavior='url(#default#homepage)';
  this.setHomePage('你的网址名称);"><font color="000000" size="2" face="大篆">设为首页</font></a>
  </body>

10.回顾日倒计时

  <script Language="Javascript">
  var timedate= new Date("December 25,2003");
  var times="圣诞节";
  var now = new Date();
  var date = timedate.getTime() - now.getTime();
  var time = Math.floor(date / (1000 * 60 * 60 * 24));
  if (time >= 0)
  document.write("现在离" times "还有: " time "天")</script>

11.单击按键打字与印刷出当前页

  <script Language="Javascript">
  <!-- Begin
  if (window.print) {
  document.write('<form>'
   '<input type=button name=print value="打字与印刷本页" '
   'onClick="javascript:window.print()"></form>');
  }
  // End -->
  </script>

12.单击开关‘另存为’当前页

  <input type="button" name="Button" value="保存本页"
  onClick="document.all.button.ExecWB(4,1)">
  <object id="button"
  width=0
  height=0
  classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
  <embed width="0" height="0"></embed>
  </object>

本文由澳门皇冠金沙网站发布于前端开发,转载请注明出处:常用小功能皇冠投注app,前端相关数据监控