有誰知道如何使用SWT中的「受控嵌入式瀏覽器」,它允許頁面操作?我只能找到有關如何使用普通SWT瀏覽器的信息,但我需要能夠與加載的頁面進行交互。謝謝。像這樣 - http://publib.boulder.ibm.com/infocenter/btt/v7r0/index.jsp?topic=%2Fcom.ibm.btt.application_presentation.doc_7.0%2Fdoc%2Freference%2Frichclient%2Fcontrolembededbrowser.html - 但沒有關於如何發起這樣的課程的指導。在SWT中使用受控嵌入式瀏覽器
0
A
回答
3
這裏是Eclipse SWT snippets website
的example另外這個帖子可能給你這方面的一些見解。 Using Java Objects in JavaScript in Eclipse SWT Browser Control
要將Java對象從Eclipse公開到JavaScript,您需要創建一個擴展BrowserFunction的類。這個類的構造函數有兩個參數;第一個是瀏覽器實例,第二個是功能,將在運行SWT瀏覽器控件的JavaScript代碼可用...的名字......
代碼片斷
BrowserFunction:
import java.io.File;
import org.eclipse.swt.browser.Browser; import org.eclipse.swt.browser.BrowserFunction;
public class ListFilesFunction extends BrowserFunction {
Browser browser = null;
String functionName = null;
public ListFilesFunction(Browser browser, String name) {
super(browser, name);
this.browser = browser;
this.functionName = name;
}
public Object function (Object[] args)
{
if (args.length == 0)
browser.execute("alert('Function " +
functionName + " requires one argument - parent folder path');");
File file = new File(args[0].toString());
if (!file.exists())
browser.execute("alert('Folder " + args[0] +
" does not exist');");
if (!file.isDirectory())
browser.execute("alert('Path " + args[0] + " must be a folder');");
return file.list();
}
}
准此功能的瀏覽器控制
public class View extends ViewPart
{
Browser browserCtl = null;
...
public void createPartControl(Composite parent) {
...
browserCtl = new Browser(parent, SWT.None);
new ListFilesFunction(browserCtl, "getFiles");
...
}
...
}
援引JAV此功能aScript:
<html>
<head>
<script type='text/javascript'>
files = getFiles("c:/");
for (i = 0; i < files.length; i++)
{
document.writeln(files[i] + "<br>");
}
</script>
</head>
<body>
</body>
</html>
相關問題
- 1. 如何在SWT瀏覽器中嵌入XUL應用程序?
- 2. 使用iframe的嵌入式瀏覽器
- 3. 使用XULRunner的嵌入式瀏覽器
- 4. 在SWT瀏覽器
- 5. 嵌入式瀏覽器
- 6. 如何在swing jframe中嵌入SWT瀏覽器
- 7. Webkit嵌入式瀏覽器禁用cookies
- 8. eclipse中的SWT瀏覽器
- 9. Apple是否接受使用UIWebView的嵌入式瀏覽器的應用程序?
- 10. 黑莓:從嵌入式瀏覽器啓動原生瀏覽器
- 11. Firefox/Gecko嵌入式瀏覽器
- 12. 嵌入式網頁瀏覽器
- 13. Java集成或嵌入式瀏覽器
- 14. 嵌入式瀏覽器的選擇
- 15. Web瀏覽器和嵌入式資源
- 16. 嵌入式視頻凍結瀏覽器
- 17. 嵌入式跨平臺Web瀏覽器?
- 18. 尋找嵌入式瀏覽器
- 19. watin attachto嵌入式瀏覽器
- 20. 在Libgdx中嵌入瀏覽器
- 21. 在Java Swing中嵌入Firefox瀏覽器
- 22. 在瀏覽器中嵌入MATLAB代碼?
- 23. 在Flex中嵌入瀏覽器
- 24. 如何在瀏覽器中使用網頁瀏覽器控件?
- 25. 代理SWT瀏覽器
- 26. UI自動化無法控制嵌入式瀏覽器
- 27. 嵌入式瀏覽器控件不顯示
- 28. 在SWT瀏覽器中控制圖像的原點
- 29. 嵌入瀏覽器組件
- 30. 如何在Visual Basic 6中嵌入瀏覽器控件?
對不起,這是很晚,但謝謝。 – 2013-09-03 14:26:03
沒關係,我的回答也晚了:),但希望這可以作爲其他人的參考 – didxga 2013-09-04 03:16:53