本文整理了Java中org.eclipse.swt.browser.Browser.evaluate()
方法的一些代码示例,展示了Browser.evaluate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Browser.evaluate()
方法的具体详情如下:
包路径:org.eclipse.swt.browser.Browser
类名称:Browser
方法名:evaluate
[英]Returns the result, if any, of executing the specified script.
Evaluates a script containing javascript commands in the context of the current document. If document-defined functions or properties are accessed by the script then this method should not be invoked until the document has finished loading (ProgressListener.completed()
gives notification of this).
If the script returns a value with a supported type then a java representation of the value is returned. The supported javascript -> java mappings are:
null
java.lang.Double
java.lang.String
java.lang.Boolean
java.lang.Object[]
SWTException
is thrown if the return value has an unsupported type, or if evaluating the script causes a javascript error to be thrown.ProgressListener.completed()
发出此通知)。null
java.lang.Double
java.lang.String
java.lang.Boolean
java.lang.Object[]
SWTException
。代码示例来源:origin: pentaho/pentaho-kettle
/**
* Ask for user Agent of the available browser.
*
* @return a string that contains the user agent of the browser.
*/
protected String getUserAgent() {
Browser browser;
try {
browser = new Browser( new Shell(), SWT.NONE );
} catch ( SWTError e ) {
log.logError( "Could not open a browser", e );
return "";
}
String userAgent = browser.evaluate( "return window.navigator.userAgent;" ).toString();
browser.close();
return userAgent;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
/**
* Executes the given script in a non-blocking way. The <code>browserCallback</code> is notified
* when the result from the operation is available.
* <p>
* Use this method instead of the <code>execute()</code> or <code>evaluate()</code> methods from
* the respective <code>Browser</code> widget when running in <em>JEE_COMPATIBILITY</em> mode.
* </p>
*
* <p>
* This method will throw an IllegalStateException if called while another script is
* still pending to be executed.
* </p>
* @param browser the browser to execute the script, must not be <code>null</code>.
* @param script the script to execute, must not be <code>null</code>.
* @param browserCallback the callback to be notified when the result from the script execution is
* available, must not be <code>null</code>.
*
* @exception IllegalStateException when another script is already being executed.
*
* @see Browser
* @see BrowserCallback
* @see org.eclipse.rap.rwt.application.Application.OperationMode
* @deprecated Use <code>Browser.evaluate( BrowserCallback )</code> instead
*/
@Deprecated
public static void evaluate( Browser browser, String script, BrowserCallback browserCallback ) {
ParamCheck.notNull( browser, "browser" );
browser.evaluate( script, browserCallback );
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
return evaluate (script, false);
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
return evaluate (script, false);
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
return evaluate (script, false);
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
return evaluate (script, false);
代码示例来源:origin: org.xworker/xworker_swt
public void run(){
Display display = new Display();
Shell shell = new Shell(display);
Browser browser = new Browser(shell, SWT.NONE);
try{
browser.setUrl(new File(World.getInstance().getPath() + "/webroot/js/xworker/InnerBrowserUtil.js").toURI().toString());
Object value = browser.evaluate("var UA = navigator.userAgent.toLowerCase();return /webkit/i.test(UA);");
if(value != null && "true".equals(value)){
isWebKit = 1;
}else{
isWebKit = 0;
}
}catch(Exception e){
}finally{
display.dispose();
}
}
}).start();
代码示例来源:origin: org.xworker/xworker_swt
public static void evaluateBrowserScript(Browser browser, String script, BrowserCallback callback, ActionContext actionContext) {
if(SwtUtils.isRWT()) {
Thing swt = World.getInstance().getThing("xworker.swt.SWT");
swt.doAction("rwtBrowserEvaluate", actionContext, "browser", browser, "script", script, "callback", callback);
}else {
browser.evaluate(script);
}
}
代码示例来源:origin: org.xworker/xworker_swt
}else{
browser.evaluate("setHtml()");
代码示例来源:origin: stackoverflow.com
boolean result = (boolean) browser.evaluate("return window.find('" + baz + "');");
System.out.println(result);
代码示例来源:origin: stackoverflow.com
public void completed(ProgressEvent progressEvent)
System.out.println(browser.evaluate("var ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\\/))\\/?\\s*(\\d+)/i) || []; if (/trident/i.test(M[1])) { tem = /\\brv[ :]+(\\d+)/g.exec(ua) || []; return 'IE ' + (tem[1] || ''); } if (M[1] === 'Chrome') { tem = ua.match(/\\b(OPR|Edge)\\/(\\d+)/); if (tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera'); } M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']; if ((tem = ua.match(/version\\/(\\d+)/i)) != null) M.splice(1, 1, tem[1]); return M.join(' ');"));
代码示例来源:origin: org.eclipse.mylyn.wikitext/ui
Object result = browser.evaluate(JAVASCRIPT_GETSCROLLTOP);
final int verticalScrollbarPos = result != null ? ((Number) result).intValue() : 0;
String xhtml = null;
代码示例来源:origin: org.xworker/xworker_swt
try{
value = browser.evaluate("return CKEDITOR.instances.data.getData()");
}catch(Throwable e){
内容来源于网络,如有侵权,请联系作者删除!