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

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

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

Window.getCurrentEvent介绍

[英]Returns the current event (used internally regardless of the emulation mode).
[中]返回当前事件(无论模拟模式如何,都在内部使用)。

代码示例

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

/**
 * Executes the event on this object only (needed for instance for onload on (i)frame tags).
 * @param event the event
 * @see #fireEvent(Event)
 */
public void executeEventLocally(final Event event) {
  final EventListenersContainer eventListenersContainer = getEventListenersContainer();
  final Window window = getWindow();
  final Object[] args = new Object[] {event};
  final Event previousEvent = window.getCurrentEvent();
  window.setCurrentEvent(event);
  try {
    event.setEventPhase(Event.AT_TARGET);
    eventListenersContainer.executeAtTargetListeners(event, args);
  }
  finally {
    window.setCurrentEvent(previousEvent); // reset event
  }
}

代码示例来源:origin: HtmlUnit/htmlunit

/**
 * Executes the event on this object only (needed for instance for onload on (i)frame tags).
 * @param event the event
 * @see #fireEvent(Event)
 */
public void executeEventLocally(final Event event) {
  final EventListenersContainer eventListenersContainer = getEventListenersContainer();
  final Window window = getWindow();
  final Object[] args = new Object[] {event};
  final Event previousEvent = window.getCurrentEvent();
  window.setCurrentEvent(event);
  try {
    event.setEventPhase(Event.AT_TARGET);
    eventListenersContainer.executeAtTargetListeners(event, args);
  }
  finally {
    window.setCurrentEvent(previousEvent); // reset event
  }
}

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

final Event previousEvent = window.getCurrentEvent();
window.setCurrentEvent(event);

代码示例来源:origin: HtmlUnit/htmlunit

final Event previousEvent = window.getCurrentEvent();
window.setCurrentEvent(event);

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

/**
 * Submits the form (at the end of the current script execution).
 *
 * @throws IOException if an IO error occurs
 */
public void jsxFunction_submit()
  throws IOException {
  boolean postpone = false;
  final Event currentEvent = getWindow().getCurrentEvent();
  if (currentEvent != null) {
    // Use target instead of srcElement because target is read-only,
    // but srcElement is writable from JavaScript.
    final SimpleScriptable src = (SimpleScriptable) currentEvent.jsxGet_target();
    postpone = src.getDomNodeOrNull() instanceof HtmlSubmitInput;
  }
  if (postpone) {
    final SgmlPage page = getDomNodeOrDie().getPage();
    final JavaScriptEngine jsEngine = page.getWebClient().getJavaScriptEngine();
    final PostponedAction action = new PostponedAction() {
      public void execute() throws IOException {
        getHtmlForm().submit((SubmittableElement) null);
      }
    };
    jsEngine.addPostponedAction(action);
  }
  else {
    getHtmlForm().submit((SubmittableElement) null);
  }
}

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

/**
 * Submits the form (at the end of the current script execution).
 *
 * @throws IOException if an IO error occurs
 */
public void jsxFunction_submit()
  throws IOException {
  boolean postpone = false;
  final Event currentEvent = getWindow().getCurrentEvent();
  if (currentEvent != null) {
    // Use target instead of srcElement because target is read-only,
    // but srcElement is writable from JavaScript.
    final SimpleScriptable src = (SimpleScriptable) currentEvent.jsxGet_target();
    postpone = src.getDomNodeOrNull() instanceof HtmlSubmitInput;
  }
  if (postpone) {
    final SgmlPage page = getDomNodeOrDie().getPage();
    final JavaScriptEngine jsEngine = page.getWebClient().getJavaScriptEngine();
    final PostponedAction action = new PostponedAction() {
      public void execute() throws IOException {
        getHtmlForm().submit((SubmittableElement) null);
      }
    };
    jsEngine.addPostponedAction(action);
  }
  else {
    getHtmlForm().submit((SubmittableElement) null);
  }
}

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

/**
 * Submits the form (at the end of the current script execution).
 *
 * @throws IOException if an IO error occurs
 */
public void jsxFunction_submit()
  throws IOException {
  boolean postpone = false;
  final Event currentEvent = getWindow().getCurrentEvent();
  if (currentEvent != null) {
    // Use target instead of srcElement because target is read-only,
    // but srcElement is writable from JavaScript.
    final SimpleScriptable src = (SimpleScriptable) currentEvent.jsxGet_target();
    postpone = src.getDomNodeOrNull() instanceof HtmlSubmitInput;
  }
  if (postpone) {
    final SgmlPage page = getDomNodeOrDie().getPage();
    final JavaScriptEngine jsEngine = page.getWebClient().getJavaScriptEngine();
    final PostponedAction action = new PostponedAction() {
      public void execute() throws IOException {
        getHtmlForm().submit((SubmittableElement) null);
      }
    };
    jsEngine.addPostponedAction(action);
  }
  else {
    getHtmlForm().submit((SubmittableElement) null);
  }
}

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

final Event previousEvent = window.getCurrentEvent();
window.setCurrentEvent(event);

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

final Event previousEvent = window.getCurrentEvent();
window.setCurrentEvent(event);

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

final Event previousEvent = window.getCurrentEvent();
window.setCurrentEvent(event);

代码示例来源:origin: net.disy.legato/legato-testing

final Event previousEvent = window.getCurrentEvent();
window.setCurrentEvent(event);

相关文章

微信公众号