BOOMR.subscribe函数未执行

BOOMR.subscribe function is not being executed

本文关键字:执行 函数 subscribe BOOMR      更新时间:2023-09-26

这是我的代码片段

这是我的表格.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <h1>Beer Selection Page</h1>
    <form method="post" action="SelectBeer.do">
        Select beer characteristics
        <p>
            Color: <select name="color" size="1">
                <option value="light">light</option>
                <option value="amber">amber</option>
                <option value="brown">brown</option>
                <option value="dark">dark</option>
            </select> <br>
            <br>
            <input type="submit" value="Submit Beer" >
    </form>
    <form action="BandwidthCalc.do">
        <br>
        <br>
        <input type="submit" value="Calculate Bandwidth" >
    </form>
</body>
</html>

这是我的BandwidthCalc.java servlet类

public class BandwidthCalc extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        RequestDispatcher view = request.getRequestDispatcher("bandwidth.jsp");
        view.forward(request, response);
    }
}

这是我的带宽.jsp文件

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bandwidth calculation</title>
</head>
<body>
    This is bandwidth page!! <br>
    <script src="./js/jquery-2.1.3.min.js" type="text/javascript"></script>
    <script src="./Boomerang/boomerang.js" type="text/javascript"></script>
    <script src="./js/testBeacon.js" type="text/javascript"></script>
    <div id="results">
    </div>
</body>
</html>

这是我的testBeacons.js文件

var bw=null,be=null,lat=null,laterr=null;
BOOMR.init({
    user_ip: '127.0.0.1',
  });
    BOOMR.subscribe('before_beacon', function(o) {
var html = "", t_name, t_other, others = [];
        if(!o.t_other) o.t_other = "";
        for(var k in o) {
            if(!k.match(/^(t_done|t_other|bw|lat|bw_err|lat_err|u|r2?)$/)) {
                if(k.match(/^t_/)) {
                    o.t_other += "," + k + "|" + o[k];
                }
                else {
                    others.push(k + " = " + o[k]);
                }
            }
        }
        if(o.t_done) { html += "This page took " + o.t_done + " ms to load<br>"; }
        if(o.t_other) {
            t_other = o.t_other.replace(/^,/, '').replace(/'|/g, ' = ').split(',');
            html += "Other timers measured: <br>";
            for(var i=0; i<t_other.length; i++) {
                html += "&nbsp;&nbsp;&nbsp;" + t_other[i] + " ms<br>";
            }
        }
        if(o.bw) { html += "Your bandwidth to this server is " + parseInt(o.bw*8/1024) + "kbps (&#x00b1;" + parseInt(o.bw_err*100/o.bw) + "%)<br>"; }
        if(o.lat) { html += "Your latency to this server is " + parseInt(o.lat) + "&#x00b1;" + o.lat_err + "ms<br>"; }
        var r = document.getElementById('results');
        r.innerHTML = html;
        if(others.length) {
            r.innerHTML += "Other parameters:<br>";
            for(var i=0; i<others.length; i++) {
                var t = document.createTextNode(others[i]);
                r.innerHTML += "&nbsp;&nbsp;&nbsp;";
                r.appendChild(t);
                r.innerHTML += "<br>";
            }
        }
});

当我运行这个BOOMR.subscribe函数时,它没有被执行。我不明白为什么?我已经使用链接包含了Boomerang文件夹http://github.com/lognormal/boomerang/

您使用的回旋镖没有任何插件,因此无法运行。自述文件顶部附近有以下文本:

您必须至少包含一个插件(不必是rt),否则信标将永远不会被实际调用。

https://github.com/lognormal/boomerang/blob/master/README.md

可能与这个特定问题无关,但禁用uBlock Origin弹出窗口阻止程序对我有效。