有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java需要根据事件发送HTTP请求

下面是java脚本,它定期(这里是7秒)将HTTP GET发送到URL(这里是google.com)。现在,当Java脚本以给定的间隔执行时,我需要检查用户是否执行了操作(如Mousedown、Mousemove等),然后只需要发送HTTP请求。请让我知道方法/解决方案

    out.println("function bustOut(){");
    out.println("var xhr = getXMLHttpRequest();");
    out.println("xhr.open(\"GET\",\"http://www.google.com\", true);");
    out.println("xhr.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded; charset=UTF-8\");");
    // some where here i need to check for the event.For example - if user had performed the action (Mousedown, Mousemove etc ) then only send the HTTP request.
    out.println("xhr.send();");
    out.println("};");
    out.println("</script></head> ");
    out.println("<body onLoad=\"setInterval(function(){ bustOut();},7000);\"></body>");

这些操作(如Mousedown、Mousemove等)将在浏览器上执行


共 (0) 个答案