利用jQuery 和 google的API实现的在线翻译 <html> <head> <title>在线翻译</title> <mce:script type="text/javascript" src="http://www.google.com/jsapi"></mce:script> <mce:script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></mce:script> <mce:script type="text/javascript"><!-- google.load("language", "1"); function initialize() { var text = $("#text").val(); google.language.detect(text, function(result) { if (!result.error && result.language) { google.language.translate(text, result.language, "en", function(result) { var translated = $("#translation"); if (result.translation) { translated.html(result.translation); } }); } }); } $(function(){ $("#begin").click(function() { BeginTranslation(); }); }); function BeginTranslation(){ $("#translation").html("翻译中.."); initialize(); return false; } // --></mce:script> </head> <body> <div> <input id="txt" type="text" value="北京欢迎您" /> <input type="button" value="翻译" id="begin"> <div id="translation"></div> </div> </body> </html>