【发布时间】:2015-02-24 22:48:30
【问题描述】:
您能否告诉我是否可以在使用客户端脚本(如 jquery 或纯 javascript)的网站中使用 Google 输入工具?是否有任何 API 可用于 Google 输入工具?
我已经用谷歌搜索了,但找不到任何东西?
谢谢
【问题讨论】:
标签: javascript jquery
您能否告诉我是否可以在使用客户端脚本(如 jquery 或纯 javascript)的网站中使用 Google 输入工具?是否有任何 API 可用于 Google 输入工具?
我已经用谷歌搜索了,但找不到任何东西?
谢谢
【问题讨论】:
标签: javascript jquery
如果你想添加谷歌输入工具,你可以使用下面的代码来添加它
// Load the Google Transliteration API
google.load("elements", "1", {
packages: "transliteration"
});
function onLoad() {
var options = {
sourceLanguage: 'en',
destinationLanguage: ['gu', 'ml', 'hi', 'kn', 'ta', 'te'],
shortcutKey: 'ctrl+m',
transliterationEnabled: true
}
// Create an instance on TransliterationControl with the required options.
var control = new google.elements.transliteration.TransliterationControl(options);
// Enable transliteration in the textfields with the given ids.
var ids = ["language"];
control.makeTransliteratable(ids);
// Show the transliteration control which can be used to toggle between English and Hindi and also choose other destination language.
control.showControl('translControl');
}
google.setOnLoadCallback(onLoad);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<textarea name="hi" rows="6" id="language" cols="6" style="width:600px;height:70px" ></textarea>
<div id='translControl'></div>
【讨论】:
Pravathy 的回答也对我有用。如果有人查看更多详细信息,只需添加以下 google docs url。
【讨论】: