Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

$wnd and $doc Calling native JavaScript with JSNI

$wnd and $doc Calling native JavaScript with JSNI
$wnd ÊÇʲô£¿
GWT provides the $wnd and $doc variables to refer to the window and document objects
GWTʹÓÃͨ¹ýJava Native methodʹÓÃËü£¬ÉùÃ÷Ò»¸önative·½·¨£¬½«º¬ÓÐJavaScriptµÄ·½·¨Ìå×¢ÊÍ¡£±àÒëÆ÷½«×¢ÊÍ¿éÄÚµÄÄÚÈÝÖð×ÖÊä³ö£¬Ê¹Ö®Óë±àÒë²úÉúµÄJavaScriptÕûºÏµ½Ò»Æð¡£
Javaµ÷ÓÃJavaScript·½·¨£º
JSNI·½·¨¶¨ÒåÐèҪʹÓÃnative¹Ø¼ü×Ö£¬²¢ÇÒÐèÒªÔÚ²ÎÊýÁбíÖ®ºó£¬½áβµÄ·ÖºÅ֮ǰ¶¨Òå¡£JSNI·½·¨µÄ¿ªÊ¼Ê¹Óà /*-{ , ½áβʹÓÃ}-*/,ÀýÈ磺
public static native void alert(String msg) /*-{
         $wnd.alert(msg);
}-*/;
ÕâÊÇgwt  Window ÀàÖеÄÔ´Âë--Ò»¸ö±ê×¼µÄjsni ·½·¨, ÎÒÃÇ¿ÉÒÔ¿´µ½,·½·¨ÊµÏÖ¾ÍÊÇÒ»Ðмòµ¥µÄjavascript ´úÂë. (ÕâÀïûÓÐÓà alert »òÕß window.alert µÄÔ­ÒòÊÇ: gwt ´úÂëÔËÐÐÔÚÒ»¸öiframeÖÐ,Èç¹ûÖ±½ÓÓÃalert»òÕßwindow.alert,ÒýÓõÄÊÇiframeÎĵµ,¶ø²»ÊÇhost page Îĵµ). ¾­¹ýÕâ¸ö·½·¨°ü×°,ÒÔºóÔÚgwt³ÌÐòÖÐʹÓà " Window.alert"  ʵ¼ÊÉϾÍÊǵ÷ÓÃÁËjavascript µÄ alert ·½·¨,µ±È»ÄãÒ²¿ÉÒÔ²»ÓÃÕâ¸ö·â×°, Ö±½ÓʵÓà $wnd.alert .
µ±ÉÏÊö·½·¨ÔÚJavaÖе÷ÓõÄʱºò£¬Êµ¼ÊÉϽ«µ÷ÓÃWindowµÄalert()·½·¨£¬½«´«ÈëµÄÄÚÈÝ´òÓ¡³öÀ´¡£ÔÚHosted ModeÏ£¬¶Ïµã¿ÉÒÔµ÷ЭÔÚÉÏÊö·½·¨ÖУ¬¿ÉÒԲ鿴´«ÈëµÄ²ÎÊý¡£
²Î¿¼ÈçÏ£º
 http://www.javaeye.com/topic/365678
http://www.webreference.com/programming/java/toolkits/
The GWT makes ingenious use of Java's native methods with something called the JavaScript Native Interface. You declare native methods with commented-out bodies that contain JavaScript. When those native methods are compiled, the GWT incorporates the commented JavaScript. Here's an example of such a native method:
Calling native JavaScript with JSNI
http://www.ibm.com/developerworks/java/library/j-ajax4/
Visual-effects libraries are becoming increasingly popular in Web application development, whether their effects are used to provide subtle user-interaction cues or just to add polish. I'd like to add some eye-candy to the Weather Reporter application. GWT doesn't provide this type of functionality, but its JavaScript Native Interface (JS


Ïà¹ØÎĵµ£º

JavascriptÁ½¸öСÇɵÄ×Ô¶¨Òå×Ö·û´®¸ñʽ»¯º¯Êý

document.close();
document.open();
function jsonFormat(template, json) {
return template.replace(/\$\{(.+?)\}/g, function ($, $1) {
return json[$1];
});
}
var links = [
{ text: "ÈËÈâËÑË÷", url: "http://renrousousuo.com" } ,
{ text: "CSDN", url: &qu ......

javascriptµ÷ÓÃiframeÖеĿؼþ

test1.htnl
 <script type="text/javascript">
      function get(){
          var ifr1 = window.parent.document.getElementById('test2Frm');
¡¡¡¡        var b1 = ifr1.contentWindow.document.get ......

Javascript Îļþ²Ù×÷

Ò»¡¢¹¦ÄÜʵÏÖºËÐÄ£ºFileSystemObject ¶ÔÏó 
    ÒªÔÚjavascriptÖÐʵÏÖÎļþ²Ù×÷¹¦ÄÜ£¬Ö÷Òª¾ÍÊÇÒÀ¿¿FileSystemobject¶ÔÏó¡£
¶þ¡¢FileSystemObject±à³Ì 
ʹÓÃFileSystemObject ¶ÔÏó½øÐбà³ÌºÜ¼òµ¥£¬Ò»°ãÒª¾­¹ýÈçϵIJ½Ö裺 ´´½¨FileSystemObject¶ÔÏó¡¢Ó¦ÓÃÏà¹Ø·½·¨¡¢·ÃÎʶÔÏóÏà¹ØÊ ......

JavaScript¶¯Ì¬Éú³ÉÊ÷Ðβ˵¥´´½¨±í¸ñ

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>ÎÞÏÞ¼¶Ê÷Ð ......

javascript ¶¯Ì¬¼ÓÔØcss¡¢js

¼æÈÝIE¡¢FireFox¡¢Chrome
//¼ÓÔØjs
function loadJs(){
    if (!getObj('script_PlData')){
        var scriptObj= document.createElement("script");
        //scriptObj.id = 'script_1';
    &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ