com.gargoylesoftware.htmlunit.javascript.host.Window.custom_eval()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 JavaScript  
字(3.7k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中com.gargoylesoftware.htmlunit.javascript.host.Window.custom_eval()方法的一些代码示例,展示了Window.custom_eval()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.custom_eval()方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.javascript.host.Window
类名称:Window
方法名:custom_eval

Window.custom_eval介绍

[英]Executes the specified script code in the scope of this window. This is used only when eval() is called on a Window other than the starting scope
[中]在此窗口范围内执行指定的脚本代码。仅当在非起始作用域的窗口上调用eval()时,才使用此选项

代码示例

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * Executes the specified script code as long as the language is JavaScript or JScript. Does
 * nothing if the language specified is VBScript.
 * @param script the script code to execute
 * @param language the language of the specified code ("JavaScript", "JScript" or "VBScript")
 * @see <a href="http://msdn.microsoft.com/en-us/library/ms536420.aspx">MSDN documentation</a>
 * @return this method always returns <code>null</code>, like Internet Explorer
 */
public Object jsxFunction_execScript(final String script, final Object language) {
  final String languageStr = Context.toString(language);
  if (language == Undefined.instance
    || "javascript".equalsIgnoreCase(languageStr) || "jscript".equalsIgnoreCase(languageStr)) {
    custom_eval(script);
    return null;
  }
  else if ("vbscript".equalsIgnoreCase(languageStr)) {
    LOG.warn("VBScript not supported in Window.execScript().");
  }
  else {
    // Unrecognized language: use the IE error message ("Invalid class string").
    throw Context.reportRuntimeError("Invalid class string");
  }
  return null;
}

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * Executes the specified script code as long as the language is JavaScript or JScript. Does
 * nothing if the language specified is VBScript.
 * @param script the script code to execute
 * @param language the language of the specified code ("JavaScript", "JScript" or "VBScript")
 * @see <a href="http://msdn.microsoft.com/en-us/library/ms536420.aspx">MSDN documentation</a>
 * @return this method always returns <code>null</code>, like Internet Explorer
 */
public Object jsxFunction_execScript(final String script, final Object language) {
  final String languageStr = Context.toString(language);
  if (language == Undefined.instance
    || "javascript".equalsIgnoreCase(languageStr) || "jscript".equalsIgnoreCase(languageStr)) {
    custom_eval(script);
    return null;
  }
  else if ("vbscript".equalsIgnoreCase(languageStr)) {
    LOG.warn("VBScript not supported in Window.execScript().");
  }
  else {
    // Unrecognized language: use the IE error message ("Invalid class string").
    throw Context.reportRuntimeError("Invalid class string");
  }
  return null;
}

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * Executes the specified script code as long as the language is JavaScript or JScript. Does
 * nothing if the language specified is VBScript.
 * @param script the script code to execute
 * @param language the language of the specified code ("JavaScript", "JScript" or "VBScript")
 * @see <a href="http://msdn.microsoft.com/en-us/library/ms536420.aspx">MSDN documentation</a>
 * @return this method always returns <code>null</code>, like Internet Explorer
 */
public Object jsxFunction_execScript(final String script, final Object language) {
  final String languageStr = Context.toString(language);
  if (language == Undefined.instance
    || "javascript".equalsIgnoreCase(languageStr) || "jscript".equalsIgnoreCase(languageStr)) {
    custom_eval(script);
    return null;
  }
  else if ("vbscript".equalsIgnoreCase(languageStr)) {
    LOG.warn("VBScript not supported in Window.execScript().");
  }
  else {
    // Unrecognized language: use the IE error message ("Invalid class string").
    throw Context.reportRuntimeError("Invalid class string");
  }
  return null;
}

相关文章

微信公众号