Close browser from java code using specific url address

前端 未结 2 1711
天命终不由人
天命终不由人 2021-01-29 16:17

1) I want to close specific browser tab using url address from my java code. As it is a client server applicaiton. I want to close browser tab using url address from my client

2条回答
  •  青春惊慌失措
    2021-01-29 16:59

    I am using following code to filter on the basis of login user. There you have to change the condition accordingly.

    WebContext webContext = WebContextFactory.get();
    Collection ss = webContext.getAllScriptSessions();
            for (ScriptSession s : ss) {
                if (s.getAttribute("uname")!=null && s.getAttribute("uname").equals(to)) {
                    Util util = new Util(s);
                    ScriptBuffer sc= new ScriptBuffer();
                    sc.appendScript("window.close()");
                    util.addScript(sc);
                }
            }
    

提交回复
热议问题