【发布时间】:2013-08-21 07:44:24
【问题描述】:
我正在尝试创建一个扩展程序来使用谷歌翻译来翻译网页。
我撰写的网址如下:url google translate + current tab + &sl=auto&tl=it&hl=&ie=UTF-8 但不起作用。怎么了?
谢谢
<script>
safari.application.addEventListener("command", performCommand, false);
function performCommand(event) {
if (event.command == "translate") {
var currentTab.url = safari.application.activeBrowserWindow.currentTab.url;
var rUrl = "http://translate.google.it/translate?u=" + encodeURIComponent(currentTab.url) + "&sl=auto&tl=it&hl=&ie=UTF-8";
safari.application.activeBrowserWindow.activeTab.url(rUrl);
}
}
</script>
【问题讨论】:
标签: javascript google-translate safari-extension