在网页中添加即时翻译器stardict

星际译王项目组资源下载列表:http://code.google.com/p/stardict-3/downloads/list

星际译王select&translate how to 即时翻译:http://www.stardict.cn/selectandtrans.php


怎样在其他网页上使用“即时翻译”?
收藏下面的这个代码,或者直接把它拖到您的工具栏:
javascript:void((function()%20{var%20element=document.createElement('script');%20element.setAttribute('src',%20'http://www.stardict.cn/initselect.php');%20document.body.appendChild(element);})())
然后打开任意网页,并且点击工具栏上的StarDict链接。


How to add "Select and Translate" in your website?
Put these codes in your website:
<script src="http://www.stardict.cn/js/stardict.js" type="text/javascript"></script>
<script type="text/javascript">
dictInit();
</script>
You can add "dict_username" and "dict_md5passwd" into this script, so you can use custom dictionaries.
eg.
<script src="http://www.stardict.cn/js/stardict.js" type="text/javascript"></script>
<script type="text/javascript">
dict_username="qinpengxiao";
dict_md5passwd="b9517b1e961f837be133cd172eb361cd";
dictInit();
</script>
Enable translate opinion:
If you want to show a "Enable translate opinion" in your webpage, put these codes in suitable place:
<span id="dict_status"></span>
* If you want to disable "Select and Translate" by default, add dict_enable=false; before dictInit();

Provide Dictionary Lookup Service in your website.
Insert these codes in your web page: Preview:

<form method="post" target="_blank"
action="http://www.stardict.cn/query.php">
<input maxlength=256 size=21 name=q /><br>
<a href="http://www.stardict.cn" target="_blank">StarDict</a>
<input type="hidden" name="cs" value="UTF-8" />
<input type="submit" value="Look Up" />
</form>


StarDict
* You may need to change "UTF-8" to the charset that you are using in your web page.


由于CSDN的编辑器中不能直接使用javascript(在编辑阶段会被直接过滤,不知CSS会否),所以没有在次页面实现即时翻译。

这个功能其实可以拓展为在网页中添加google custom search,同样的道理。

你可能感兴趣的:(JavaScript,service,search,工具,Dictionary,website)