$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 ¿â²»Ê¤Ã¶¾Ù£¬jQuery, MooTools, Prototype, Dojo, YUI¡£ÕâЩ JavaScript ¿â¹¦Äܷḻ£¬¼ÓÉÏËüÃǵIJå¼þ£¬¼¸ºõÄÜʤÈÎÈκι¤×÷£¬È»¶øÕâÊÇÓдú¼ÛµÄ£¬ÕâЩ¿âÍùÍùµ¼ÖÂÄãµÄÍøÒ³³ß´çÓ·Öס£ÔÚijЩ³¡ºÏ£¬Èç¹ûÄãÖ»ÏëÍê³ÉÌØ¶¨µÄ¹¤×÷£¬¿ÉÒÔʹÓà һЩ¹¦ÄܸüרһµÄÇáÁ¿¿â£¬±¾ÎĽéÉÜÁË40¸ö·Ç³£³öÉ«µÄÇáÁ¿¼¶ JavaScript ¿â¡ ......
ÎÒgoogleÒ»ÏÂ,ÒÑÓÐÈË·ÒëÁË´ËÎÄ.¸Ð¾õ±ÈÎÒ·ÒëµÄÒªºÃ!ÊÇÒëÑÔÕ¾·ÒëµÄ
¼ûwww.yeeyan.com/articles/view/92135/47626/dz
ÔÎļû:http://code.google.com/intl/zh-CN/speed/articles/optimizing-javascript.html
²»ºÏÊʵĵط½,Çë´ó¼ÒÖ¸³öÀ´!Ï£Íû¶ÔÄãÓÐÓÃ!
&nb ......
ÀûÓÃjsÀ´¶¯Ì¬´´½¨±í¸ñÓÐÁ½ÖÖ¸ñʽ£¬appendChild()ºÍinsertRow¡¢insertCell()¡£Á½ÖÖ·½Ê½Æäʵ²î²»¶à£¬µ«µÚÒ»ÖÖÓпÉÄÜÔÚIEÉÏÓÐÎÊÌ⣬ËùÒÔÍÆ¼ö´ó¼ÒʹÓõڶþÖÖÁË£¬Ö±½Ó˵°É¡£
1¡¢inserRow()ºÍinsertCell()º¯Êý
insertRow()º¯Êý¿ÉÒÔ´ø²ÎÊý£¬ÐÎʽÈçÏ£º
insertRow(index)£ºindex´Ó0¿ªÊ¼
¡¡¡¡Õâ¸öº¯Êý½«ÐÂÐÐÌí¼Óµ½indexµÄÄÇÒ»ÐÐÇ ......
1.<select></select>±êǩӦÓÃ
ͨ³£µÄд·¨ÊÇ£º
<select onchange="javascript:windwo.open(this.options[this.selectedIndex].value)">
<option>MAIN</option>
& ......