本文整理了Java中com.gargoylesoftware.htmlunit.javascript.host.Window.getDomNodeOrDie()
方法的一些代码示例,展示了Window.getDomNodeOrDie()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getDomNodeOrDie()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.javascript.host.Window
类名称:Window
方法名:getDomNodeOrDie
暂无
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Returns the current HtmlUnit DOM selection ranges.
* @return the current HtmlUnit DOM selection ranges
*/
private List<Range> getRanges() {
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
return page.getSelectionRanges();
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Returns the current HtmlUnit DOM selection range.
* @return the current HtmlUnit DOM selection range
*/
private Range getPageSelection() {
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
return page.getSelection();
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Returns the current HtmlUnit DOM selection ranges.
* @return the current HtmlUnit DOM selection ranges
*/
private List<Range> getRanges() {
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
return page.getSelectionRanges();
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Returns the current HtmlUnit DOM selection range.
* @return the current HtmlUnit DOM selection range
*/
private Range getPageSelection() {
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
return page.getSelection();
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Returns the current HtmlUnit DOM selection range.
* @return the current HtmlUnit DOM selection range
*/
private Range getPageSelection() {
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
return page.getSelection();
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Makes the current range the active selection.
*
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536735.aspx">MSDN doc</a>
*/
@JsxFunction
public void select() {
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
page.setSelectionRange(range_);
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Makes the current range the active selection.
*
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536735.aspx">MSDN doc</a>
*/
@JsxFunction
public void select() {
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
page.setSelectionRange(range_);
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* JavaScript constructor.
* @param o the object to enumerate over
*/
@JsxConstructor
public void jsConstructor(final Object o) {
if (Undefined.instance == o) {
collection_ = HTMLCollection.emptyCollection(getWindow().getDomNodeOrDie());
}
else if (getBrowserVersion().hasFeature(JS_ENUMERATOR_CONSTRUCTOR_THROWS)) {
throw Context.reportRuntimeError("TypeError: object is not enumerable");
}
else if (o instanceof HTMLCollection) {
collection_ = (HTMLCollection) o;
}
else if (o instanceof HTMLFormElement) {
collection_ = ((HTMLFormElement) o).getElements();
}
else {
throw Context.reportRuntimeError("TypeError: object is not enumerable (" + String.valueOf(o) + ")");
}
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* JavaScript constructor.
* @param o the object to enumerate over
*/
@JsxConstructor
public void jsConstructor(final Object o) {
if (Undefined.instance == o) {
collection_ = HTMLCollection.emptyCollection(getWindow().getDomNodeOrDie());
}
else if (getBrowserVersion().hasFeature(JS_ENUMERATOR_CONSTRUCTOR_THROWS)) {
throw Context.reportRuntimeError("TypeError: object is not enumerable");
}
else if (o instanceof HTMLCollection) {
collection_ = (HTMLCollection) o;
}
else if (o instanceof HTMLFormElement) {
collection_ = ((HTMLFormElement) o).getElements();
}
else {
throw Context.reportRuntimeError("TypeError: object is not enumerable (" + String.valueOf(o) + ")");
}
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Creates a modeless dialog box that displays the specified HTML document.
* @param url the URL of the document to load and display
* @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
* @param features string that specifies the window ornaments for the dialog window
* @return a reference to the new window object created for the modeless dialog
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536761.aspx">MSDN Documentation</a>
*/
public Object jsxFunction_showModelessDialog(final String url, final Object arguments, final String features) {
final WebWindow ww = getWebWindow();
final WebClient client = ww.getWebClient();
try {
final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
final DialogWindow dialog = client.openDialogWindow(completeUrl, ww, arguments);
final Window jsDialog = (Window) dialog.getScriptObject();
return jsDialog;
}
catch (final IOException e) {
throw Context.throwAsScriptRuntimeEx(e);
}
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* {@inheritDoc}
*/
@Override
@JsxFunction
public HTMLCollection getElementsByTagName(final String tagName) {
final DomNode firstChild = getDomNodeOrDie().getFirstChild();
if (firstChild == null) {
return HTMLCollection.emptyCollection(getWindow().getDomNodeOrDie());
}
final HTMLCollection collection = new HTMLCollection(getDomNodeOrDie(), false) {
@Override
protected boolean isMatching(final DomNode node) {
final String nodeName;
if (getBrowserVersion().hasFeature(JS_XML_GET_ELEMENTS_BY_TAG_NAME_LOCAL)) {
nodeName = node.getLocalName();
}
else {
nodeName = node.getNodeName();
}
return nodeName.equals(tagName);
}
};
return collection;
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Creates a modeless dialog box that displays the specified HTML document.
* @param url the URL of the document to load and display
* @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
* @param features string that specifies the window ornaments for the dialog window
* @return a reference to the new window object created for the modeless dialog
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536761.aspx">MSDN Documentation</a>
*/
public Object jsxFunction_showModelessDialog(final String url, final Object arguments, final String features) {
final WebWindow ww = getWebWindow();
final WebClient client = ww.getWebClient();
try {
final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
final DialogWindow dialog = client.openDialogWindow(completeUrl, ww, arguments);
final Window jsDialog = (Window) dialog.getScriptObject();
return jsDialog;
}
catch (final IOException e) {
throw Context.throwAsScriptRuntimeEx(e);
}
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Creates a modeless dialog box that displays the specified HTML document.
* @param url the URL of the document to load and display
* @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
* @param features string that specifies the window ornaments for the dialog window
* @return a reference to the new window object created for the modeless dialog
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536761.aspx">MSDN Documentation</a>
*/
public Object jsxFunction_showModelessDialog(final String url, final Object arguments, final String features) {
final WebWindow ww = getWebWindow();
final WebClient client = ww.getWebClient();
try {
final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
final DialogWindow dialog = client.openDialogWindow(completeUrl, ww, arguments);
final Window jsDialog = (Window) dialog.getScriptObject();
return jsDialog;
}
catch (final IOException e) {
throw Context.throwAsScriptRuntimeEx(e);
}
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Sets the text contained within the range.
* @param text the text contained within the range
*/
public void jsxSet_text(final String text) {
collapsed_ = false;
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
final Range selection = page.getSelection();
// currently only working for text input and textarea
if (selection.getStartContainer() == selection.getEndContainer()) {
if (selection.getStartContainer() instanceof HtmlTextInput) {
final HtmlTextInput input = (HtmlTextInput) selection.getStartContainer();
final String oldValue = input.getValueAttribute();
input.setValueAttribute(oldValue.substring(0, input.getSelectionStart()) + text
+ oldValue.substring(input.getSelectionEnd()));
}
else if (selection.getStartContainer() instanceof HtmlTextArea) {
final HtmlTextArea input = (HtmlTextArea) selection.getStartContainer();
final String oldValue = input.getText();
input.setText(oldValue.substring(0, input.getSelectionStart()) + text
+ oldValue.substring(input.getSelectionEnd()));
}
}
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Creates a modeless dialog box that displays the specified HTML document.
* @param url the URL of the document to load and display
* @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
* @param features string that specifies the window ornaments for the dialog window
* @return a reference to the new window object created for the modeless dialog
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536761.aspx">MSDN Documentation</a>
*/
@JsxFunction(IE)
public Object showModelessDialog(final String url, final Object arguments, final String features) {
final WebWindow webWindow = getWebWindow();
final WebClient client = webWindow.getWebClient();
try {
final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
final DialogWindow dialog = client.openDialogWindow(completeUrl, webWindow, arguments);
return dialog.getScriptableObject();
}
catch (final IOException e) {
throw Context.throwAsScriptRuntimeEx(e);
}
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Creates a modeless dialog box that displays the specified HTML document.
* @param url the URL of the document to load and display
* @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
* @param features string that specifies the window ornaments for the dialog window
* @return a reference to the new window object created for the modeless dialog
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536761.aspx">MSDN Documentation</a>
*/
@JsxFunction(IE)
public Object showModelessDialog(final String url, final Object arguments, final String features) {
final WebWindow webWindow = getWebWindow();
final WebClient client = webWindow.getWebClient();
try {
final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
final DialogWindow dialog = client.openDialogWindow(completeUrl, webWindow, arguments);
return dialog.getScriptableObject();
}
catch (final IOException e) {
throw Context.throwAsScriptRuntimeEx(e);
}
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Changes the start position of the range.
* @param unit specifies the units to move
* @param count the number of units to move
* @return the number of units moved
*/
public int jsxFunction_moveStart(final String unit, final Object count) {
if ("characters".equals(unit)) {
LOG.info("moveStart('" + unit + "' is not yet supported.");
}
int c = 1;
if (count != Undefined.instance) {
c = (int) Context.toNumber(count);
}
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
final Range selection = page.getSelection();
// currently only working for text input and textarea
if (selection.getStartContainer() == selection.getEndContainer()) {
if (selection.getStartContainer() instanceof HtmlTextInput) {
final HtmlTextInput input = (HtmlTextInput) selection.getStartContainer();
selection.setStart(input, selection.getStartOffset() + c);
}
else if (selection.getStartContainer() instanceof HtmlTextArea) {
final HtmlTextArea input = (HtmlTextArea) selection.getStartContainer();
selection.setStart(input, selection.getStartOffset() + c);
}
}
return c;
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Retrieves the text contained within the range.
* @return the text contained within the range
*/
public Object jsxGet_text() {
if (collapsed_) {
return "";
}
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
final Range selection = page.getSelection();
// currently only working for text input and textarea
if (selection.getStartContainer() == selection.getEndContainer()) {
if (selection.getStartContainer() instanceof HtmlTextInput) {
final HtmlTextInput input = (HtmlTextInput) selection.getStartContainer();
return input.getValueAttribute().substring(input.getSelectionStart(), input.getSelectionEnd());
}
else if (selection.getStartContainer() instanceof HtmlTextArea) {
final HtmlTextArea input = (HtmlTextArea) selection.getStartContainer();
return input.getText().substring(input.getSelectionStart(), input.getSelectionEnd());
}
}
return "";
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Changes the start position of the range.
* @param unit specifies the units to move
* @param count the number of units to move
* @return the number of units moved
*/
public int jsxFunction_moveStart(final String unit, final Object count) {
if ("characters".equals(unit)) {
LOG.info("moveStart('" + unit + "' is not yet supported.");
}
int c = 1;
if (count != Undefined.instance) {
c = (int) Context.toNumber(count);
}
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
final Range selection = page.getSelection();
// currently only working for text input and textarea
if (selection.getStartContainer() == selection.getEndContainer()) {
if (selection.getStartContainer() instanceof HtmlTextInput) {
final HtmlTextInput input = (HtmlTextInput) selection.getStartContainer();
selection.setStart(input, selection.getStartOffset() + c);
}
else if (selection.getStartContainer() instanceof HtmlTextArea) {
final HtmlTextArea input = (HtmlTextArea) selection.getStartContainer();
selection.setStart(input, selection.getStartOffset() + c);
}
}
return c;
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Changes the end position of the range.
* @param unit specifies the units to move
* @param count the number of units to move
* @return the number of units moved
*/
public int jsxFunction_moveEnd(final String unit, final Object count) {
if ("characters".equals(unit)) {
LOG.info("moveEnd('" + unit + "' is not yet supported.");
}
int c = 1;
if (count != Undefined.instance) {
c = (int) Context.toNumber(count);
}
final HtmlPage page = (HtmlPage) getWindow().getDomNodeOrDie();
final Range selection = page.getSelection();
// currently only working for text input and textarea
if (selection.getStartContainer() == selection.getEndContainer()) {
if (selection.getStartContainer() instanceof HtmlTextInput) {
final HtmlTextInput input = (HtmlTextInput) selection.getStartContainer();
selection.setEnd(input, selection.getEndOffset() + c);
}
else if (selection.getStartContainer() instanceof HtmlTextArea) {
final HtmlTextArea input = (HtmlTextArea) selection.getStartContainer();
selection.setEnd(input, selection.getEndOffset() + c);
}
}
return c;
}
内容来源于网络,如有侵权,请联系作者删除!