我可以在单页应用程序中使用浏览器Navigation Timing API处理Ajax事件吗?如果没有,什么是好的工具?

我可以在单页应用程序中使用浏览器Navigation Timing API处理Ajax事件吗?如果没有,什么是好的工具?,第1张

我可以在单页应用程序中使用浏览器Navigation Timing API处理Ajax事件吗?如果没有,什么是好的工具?

1-正确,window.performance与页面加载有关。请参见下面的示例,该示例显示了这一点:

    <button id='searchButton'>Look up Cities</button>    <br>    Timing info is same? <span id='results'></span>    <script type="text/javascript" src="//pre.jquery.com/jquery-1.9.1.min.js"></script>    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>    <script type="text/javascript">        jQuery('#searchButton').on('click', function(e){ // deep copy the timing info var perf1 = jQuery.extend(true, {}, performance.timing);   // do something async jQuery.getJSON('http://ws.geonames.org/searchJSON?featureClass=P&style=full&maxRows=10&name_startsWith=Denv', function() {     // get another copy of timing info     var perf2 = jQuery.extend(true, {}, performance.timing);     // show if timing information has changed     jQuery('#results').text( _.isEqual( perf1, perf2 ) ); }); return false;        });    </script>

另外,即使您确实可以使用它,您也会从不支持该对象的旧浏览器中丢失数据。

2-
Boomerang项目似乎超出了Web计时API,还支持较旧的浏览器。本次会议上列出的当前维护者正在与幻灯片和示例代码进行交谈。抱歉,没有直接链接。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4942326.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-13
下一篇 2022-11-13

发表评论

登录后才能评论

评论列表(0条)

保存