Site Notice
hello, world
Difference between revisions of "Youdao translate"
From Project-EPB Commons
(Created page with "<html> <label for="origin">原文</label> <textarea id="origin" style="max-width: 100%; min-width: 100%; min-height: 4em"></textarea> <label>翻译</label> <pre id="translatio...") |
m ([InPageEdit] 没有编辑摘要) |
||
Line 25: | Line 25: | ||
}) | }) | ||
} | } | ||
+ | </script> | ||
+ | </html> |
Revision as of 21:37, 25 June 2020
<html> <label for="origin">原文</label> <textarea id="origin" style="max-width: 100%; min-width: 100%; min-height: 4em"></textarea> <label>翻译</label> <pre id="translation"></pre> <button onclick="translate">翻 译</button>
<script>window.translate = function() { var text = $('#origon').val(); if (text === '') return; $.ajax({
url: 'https://fanyi.youdao.com/openapi.do', data: { keyfrom: 'youdaoci', key: '694691143', type: 'data', doctype: 'jsonp', version: '1.1', q: text }, dataType: 'jsonp'
}).done((data)=>{
var translation = data.translation[0]; $('#translation').text(translation);
}) } </script> </html>