本文整理了Java中netscape.javascript.JSObject.eval()
方法的一些代码示例,展示了JSObject.eval()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSObject.eval()
方法的具体详情如下:
包路径:netscape.javascript.JSObject
类名称:JSObject
方法名:eval
[英]Evaluates a JavaScript expression. The expression is a string of JavaScript source code which will be evaluated in the context given by "this".
[中]计算JavaScript表达式的值。表达式是一个JavaScript源代码字符串,将在“this”给定的上下文中进行计算。
代码示例来源:origin: stackoverflow.com
@Override
public void init() {
String jsCallbackName = getParameter("applet_ready_callback");
JSObject jsObject = JSObject.getWindow(this);
jsObject.eval(jsCallbackName + "()");
}
代码示例来源:origin: stackoverflow.com
@Override
public void init() {
// some code
JSObject jsObject = JSObject.getWindow(this);
jsObject.eval("your javascript");
}
代码示例来源:origin: stackoverflow.com
String callbackFunction;
public void RegisterCallback(String functionName)
{
callbackFunction = functionName;
}
void UseCallbackFunction()
{
if (callbackFunction == null) return;
JSObject win = (JSObject) JSObject.getWindow(this);
win.eval(callbackFunction);
}
代码示例来源:origin: stackoverflow.com
public void jsAppletCall() {
// do you java stuff here
// then
// call the javascript from the applet using the JSOBject
JSObject win = JSObject.getWindow(this);
win.eval("callJSFromMyAppletMessage();");
}
代码示例来源:origin: stackoverflow.com
public void init() {
JSObject document = JSObject.getWindow(this);
String evalString = "document.getElementById('secondAppletPanel').innerHTML = ";
document.eval(evalString + secondAppletHtmlString);
}
代码示例来源:origin: stackoverflow.com
JSObject win = JSObject.getWindow(this);
win.eval("document.getElementById('#applet').innerHTML=''", null);
代码示例来源:origin: stackoverflow.com
JSObject jsWin = getHostServices().getWebContext();
if (jsWin != null) {
jsWin.eval("show_alert();");
}
代码示例来源:origin: stackoverflow.com
Executor exe = Executors.newSingleThreadExecutor();
final JSObject page = JSObject.getWindow(applet);
if (page == null) {
/* Break here, no connection could be made */
}
final String javascriptFunction = "yourJavaScriptFunction()";
executor.execute(new Runnable() {
public void run() {
page.eval(javascriptFunction);
}
});
代码示例来源:origin: com.machinepublishers/jbrowserdriver
/**
* {@inheritDoc}
*/
@Override
public String getCssValue(final String name) {
return AppThread.exec(contextItem.statusCode, () -> {
validate(false);
return cleanUpCssVal((String) (node.eval(new StringBuilder()
.append("var me = this;")
.append("(function(){")
.append(" return window.getComputedStyle(me).getPropertyValue('")
.append(name)
.append("');")
.append("})();").toString())));
});
}
代码示例来源:origin: com.machinepublishers/jbrowserdriver
/**
* {@inheritDoc}
*/
@Override
public boolean isDisplayed() {
return AppThread.exec(contextItem.statusCode, () -> {
validate(false);
return (Boolean) node.eval(IS_VISIBLE);
});
}
代码示例来源:origin: com.machinepublishers/jbrowserdriver
/**
* {@inheritDoc}
*/
@Override
public void clear() {
AppThread.exec(contextItem.statusCode, () -> {
validate(false);
contextItem.httpListener.get().resetStatusCode();
node.eval(SCROLL_INTO_VIEW);
node.call("focus");
node.eval("this.value='';");
return null;
});
}
代码示例来源:origin: com.machinepublishers/jbrowserdriver
if (callback) {
argList.add(null);
node.eval(new StringBuilder().append("(function(){")
.append("this.").append(jsNames.callback).append(" = function(){")
.append(jsNames.callbackVal).append(" = arguments && arguments.length > 0? arguments[0] : null;")
.append("};").toString());
} else {
node.eval(new StringBuilder().append("this.").append(jsNames.exec).append(" = function(){")
.append("return (function(){").append(script).append("}).apply(this, arguments);")
.append("};").toString());
return t;
} finally {
node.eval("delete " + "this." + jsNames.exec + ";");
if (callback) {
node.eval("delete " + "this." + jsNames.callback + ";");
代码示例来源:origin: com.barchart.pivot/pivot-wtk
return window.eval(script);
} catch (Throwable throwable) {
throw new UnsupportedOperationException(throwable);
代码示例来源:origin: stackoverflow.com
jsObject.eval("window['" + keysFunctionName + "'] = function(jsObject) { return Object.keys(jsObject) }");
JSObject propertiesNamesJsObject = (JSObject)globalContext.call(keysFunctionName, new Object[] { jsObject });
jsObject.eval("delete(window['" + keysFunctionName + "'])");
代码示例来源:origin: org.apache.pivot/pivot-wtk
/**
* Evaluates a script in the page context and returns the result.
*
* @param script
* @param application
*/
public static Object eval(String script, Application application) {
if (application == null) {
throw new IllegalArgumentException("application is null.");
}
HostApplet applicationHostApplet = null;
for (HostApplet hostApplet : hostApplets) {
if (hostApplet.getApplication() == application) {
applicationHostApplet = hostApplet;
break;
}
}
if (applicationHostApplet == null) {
throw new IllegalArgumentException("No applet is hosting the given application.");
}
try {
JSObject window = JSObject.getWindow(applicationHostApplet);
return window.eval(script);
} catch (Throwable throwable) {
throw new UnsupportedOperationException(throwable);
}
}
代码示例来源:origin: stackoverflow.com
sb.append("{\n");
final JSObject js = (JSObject) o;
final JSObject keys = (JSObject) js.eval(getKeys);
boolean needComma = false;
for (int i = 0;; i++) {
代码示例来源:origin: com.machinepublishers/jbrowserdriver
/**
* {@inheritDoc}
*/
@Override
public String getText() {
return AppThread.exec(contextItem.statusCode, () -> {
validate(false);
if ((Boolean) node.eval(IS_VISIBLE)) {
String textAttribute = "TEXTAREA".equals(node.getMember("tagName")) ? "textContent" : "innerText";
Object text = node.getMember(textAttribute);
return text instanceof String ? ((String) text).trim() : "";
}
return "";
});
}
代码示例来源:origin: com.machinepublishers/jbrowserdriver
/**
* {@inheritDoc}
*/
@Override
public void sendKeys(final CharSequence... keys) {
AppThread.exec(contextItem.statusCode, () -> {
validate(true);
node.eval(SCROLL_INTO_VIEW);
node.call("focus");
return null;
});
final boolean fileChooser = node instanceof HTMLInputElement && "file".equalsIgnoreCase(getAttribute("type"));
if (fileChooser) {
click();
}
contextItem.context.get().robot.get().keysType(keys);
if (fileChooser) {
contextItem.context.get().robot.get().typeEnter();
}
}
代码示例来源:origin: com.machinepublishers/jbrowserdriver
contextItem.statusCode, () -> {
validate(false);
return node.eval("(function(){return this." + jsNames.callbackVal + ";})();");
});
if (!(result instanceof String) || !"undefined".equals(result.toString())) {
contextItem.statusCode, () -> {
validate(false);
node.eval("delete " + jsNames.callbackVal + ";");
return null;
});
代码示例来源:origin: com.machinepublishers/jbrowserdriver
/**
* {@inheritDoc}
*/
@Override
public Point locate() {
AppThread.exec(contextItem.statusCode, () -> {
validate(false);
node.eval(SCROLL_INTO_VIEW);
return null;
});
return AppThread.exec(contextItem.statusCode, () -> {
validate(true);
JSObject obj = (JSObject) node.call("getBoundingClientRect");
double y = Double.parseDouble(obj.getMember("top").toString());
double x = Double.parseDouble(obj.getMember("left").toString());
y = y < 0d ? 0d : y;
x = x < 0d ? 0d : x;
final org.openqa.selenium.Point frameLocation = contextItem.selectedFrameLocation();
return new Point((int) Math.rint(x) + 1 + frameLocation.getX(),
(int) Math.rint(y) + 1 + frameLocation.getY());
});
}
内容来源于网络,如有侵权,请联系作者删除!