转帖:http://www.denisdeng.com/?p=1143
不知道如何翻译它,只好直接用它作为标题。在《Hight Performance Javascript》一书中对此有过描述,详情可查看本书,这里只对此做一个简单描述。该技巧适用于以下场景:
只关注数据是否被发送到服务器,客户端对该请求是否做出响应无关紧要。在对站点数据进行分析时,这种技巧正可大行其道。即:
var url = '/status_tracker.php';
var params = [
'step=2',
'time=1248027314'
];
(new Image()).src = url + '?' + params.join('&');
同样,你可以监听Image的load事件来确定数据是否发送成功。
var url = '/status_tracker.php';
var params = [
'step=2',
'time=1248027314'
];
var beacon = new Image();
beacon.src = url + '?' + params.join('&');
beacon.onload = function() {
if (this.width == 1) {
// Success.
}
else if (this.width == 2) {
// Failure; create another beacon and try again.
}
};
beacon.onerror = function() {
// Error; wait a bit, then create another beacon and try again.
};
这种方法的局限性在于只能以get的方式提交数据,这样提交的数据也就有了字节限制。故在真正用到该技巧的时候,还是根据具体的功能需求酌情使用。
在Minimize redirects一文中,在Track web traffic in the background一节中,你可以看到对该技巧类似的描述。
分享到:
相关推荐
图像信标编码器执行mvn测试以查看结果。
一款可以模拟BLE蓝牙的beacon信号的APP。 Beacon Simulator This app transforms your Android device into a virtual BLE beacon advertiser and transmitter. You can create your own collection of beacon ...
BEACON
android下beacon 开发示例程序
Android使用android-beacon-library接收beacon
android扫描beacon设备例子,例子中使用html显示ui,应用扫描到设备后,通知页面。 本例子中把beacon设备扫描简单封装了一下,功能包括发现设备,更新设备,设备丢失败检查等。
android-beacon-libary的使用android-beacon-libary的使用android-beacon-libary的使用android-beacon-libary的使用android-beacon-libary的使用android-beacon-libary的使用android-beacon-libary的使用android-...
2、无线-beacon 3、无线-认证 4、无线-认证全 无线抓包分析: Beacon 包:(无线没设密码) 2、beacon有无线密码 WPA1:WPA中有CCMP(AES)、无TKIP。无RSN 切换为TKIPWPA中有TKIP。无RSN WPA2:...
nRF Beacon Service,nRF Beacon开发必备!
车载自组织网(vehicular Ad hoc networks,VANETs)中的车辆通过周期交互beacon实现信息共享,从而提高交通安全,然而VANETs无线网络特性系统易遭受多类攻击,特别是对beacon的传输攻击,即干扰beacon的传输,其...
.cobaltstrike.beacon_keys
Cobal_Strike踩坑记录-DNS Beacon1
Delphi Beacon demo program file
Solutions architects of all types―venture capitalists, founders, CEOs, strategists, product managers, CTOs, business developers, and programmers―will learn about the following from reading Beacon ...
802.11_beacon帧结构
在Android平台上,基于库AltBeacon的Beacon开发demo
IEEE 802.11 WLAN - Beacon Frame
android beacon 开发库 可以放心使用,里面包含源代码和测试代码
Beacon对蓝牙低功耗(BLE)芯片提出挑战.pdf
The nRF Beacon application lets you explore the full range of possibilities for beacons using Bluetooth Smart technology. The application has been designed to demonstrate all features of the nRF8122 ...