我正在建立一个带有网页的HttpUrlConnection
。现在我想要在此网页上执行javascript
代码段。我怎么能这样做?
答案 0 :(得分:2)
你可以尝试:
private static ScriptEngineManager mgr = null;
private static ScriptEngine engine = null;
mgr = new ScriptEngineManager();
engine = mgr.getEngineByName("JavaScript");
Object eval = engine.eval(s); // s is javascript code
答案 1 :(得分:1)