1 pièce(s) jointe(s)
[SWT] Browser.setText() qui agit étrangement.
Bonjour à tous, j'ai un petit souci avec un composant SWT.Browser qui m'affiche une alerte incompréhensible.
J'ai voulu tester un peu l'API Google StreetView dans un browser alors j'ai fait une petite page (en fait j'ai rien fait du tout, j'ai copié l'exemple du site de Google.) Et j'obtiens l'alerte suivrante
http://www.developpez.net/forums/att...1&d=1245854851(déconcertant, non ?)
mon code est simplissime (le voila)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| 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\" xmlns: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();
} |
Le problème doit plus ou moins venir de l'Api car lorsque je ne l'inclue pas je n'ai pas d'erreurs.
Ceci dit cette même page marche parfaitement sur tous mes webbrosers standards.
Plus surprenant encore, je n'obtiens pas d'erreur si mon deuxième tag Script n'est pas fermé (bon il ne se passe rien mais ça ne fait pas d'erreur ...)
Donc je suis ennuyé, si vous avez une idée j'en serais très friand.