我尝试这样做:
$("iframe.cke_dialog_ui_input_file").contents()
但它返回:
< #document(gquery, error getting the element string representation: (TypeError) @com.google.gwt.dom.client.DOMImplMozilla::toString(Lcom/google/gwt/dom/client/Element;)([JavaScript object(8570)]): doc is null)/>
但是文档不为空!
请帮我解决这个问题:(
UPD。 HTML 代码:
<iframe id="cke_107_fileInput" class="cke_dialog_ui_input_file" frameborder="0" src="javascript:void(0)" title="Upload Image" role="presentation" allowtransparency="0">
<html lang="en" dir="ltr">
<head>
<body style="margin: 0; overflow: hidden; background: transparent;">
<form lang="en" action="gui/ckeditor/FileUploadServlet?CKEditor=gwt-uid-7&CKEditorFuncNum=0&langCode=en" dir="ltr" method="POST" enctype="multipart/form-data">
<label id="cke_106_label" style="display:none" for="cke_107_fileInput_input">Upload Image</label>
<input id="cke_107_fileInput_input" type="file" size="38" name="upload" aria-labelledby="cke_106_label">
</form>
<script>
window.parent.CKEDITOR.tools.callFunction(90);window.onbeforeunload = function() {window.parent.CKEDITOR.tools.callFunction(91)}
</script>
</body>
</html>
</iframe>
最佳答案
首先像现有的 cod 一样使用 javascript 获取 iframe 元素并将其存储到 GWT 的 Iframe
IFrameElement iframe = (IFrameElement) element;
现在使用 iframe 获取内容
iframe.getContentDocument().getBody().getInnerText();
希望它能帮助您获得值(value)观。
关于java - 如何使用 GWT 查询获取 iframe 的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19220293/