我有一个 SWT.Browser 小部件的小问题,它会抛出一个非常令人费解的警报。
我试图在浏览器中测试 Google StreetView API,所以我创建了这个页面(实际上我什么都没做,只是从 Google 的代码片段中粘贴了它。)我收到以下消息:
(令人费解,不是吗?)
我的代码很简单(在这里)
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
shell.setText("Tentative API Google avec un SWT.Browser");
shell.setLayout(new GridLayout());
final Browser browser = new Browser(shell,SWT.BORDER);
browser.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
browser.setText("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"+
"<html xmlns=\"http://www.w3.org/1999/xhtml\" mlns:v=\"urn:schemas-microsoft-com:vml\">"+
"<head>"+
"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>"+
"<script src=\"http://maps.google.com/maps?file=api&v=2.x&key=AnyKey\" type=\"text/javascript\"></script>" +
"<title>"+
"Google Maps JavaScript API Example: Simple Streetview Example"+
"</title>" +
"<script type=\"text/javascript\">var myPano;function initialize(){var fenwayPark = new GLatLng(42.345573,-71.098326);panoramaOptions = { latlng:fenwayPark };myPano = new GStreetviewPanorama(document.getElementById(\"pano\"), panoramaOptions);GEvent.addListener(myPano, \"error\", handleNoFlash);}function handleNoFlash(errorCode){if(errorCode == FLASH_UNAVAILABLE){alert(\"Error: Flash doesn't appear to be supported by your browser\");return;}}</script>" +
"</head>" +
"<body onload=\"initialize()\" onunload=\"GUnload()\">" +
"<div name=\"pano\" id=\"pano\" style=\"width: 500px; height: 300px\">" +
"</div>" +
"</body>" +
"</html>");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
问题可能(或多或少)来自 API,因为当我不包含它时,我不会收到任何错误。无论如何,这个页面在任何标准浏览器上都能完美运行。更令人惊讶的是,如果我的第二个Script标签没有关闭,我不会收到任何错误(那么什么都不会发生,如果我们这样做,当我绝对没有代码时,我绝对没有错误......)
我站在这里......对该怎么做有点困惑......(非常欢迎任何帮助......)