サンプルコード ———————————————————————-
index.html
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>エキサイト翻訳にリンクするサンプル</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<p><a href="javascript:test1();">エキサイトの英語翻訳にリンク。別ウインドウで開きます。</a></p>
<p><a href="javascript:test2();">エキサイトの韓国語翻訳にリンク。別ウインドウで開きます。</a></p>
<p>試験用の日本語です。</p>
</body>
test.js
function test1() {
var add1 = ‘http://www.excite.co.jp/world/english/web/?wb_url=’;
var add2 = encodeURIComponent(location.href);
var add3 = ‘&wb_lp=JAEN&wb_dis=2’
window.open(add1 + add2 + add3)
}
function test2() {
var add1 = ‘http://www.excite.co.jp/world/korean/web/?wb_url=’;
var add2 = encodeURIComponent(location.href);
var add3 = ‘&wb_lp=JAKO&wb_dis=2’
window.open(add1 + add2 + add3)
}
実際に動作するサンプル ———————————————————————-
動作を確認したウェブブラウザ
– OK – Mac Firefox 2.0 – OK – Mac Safari 2.0 – OK – Windows Firefox 2.0 – OK – Windows Internet Explorer 7.0
その他
– ブックマークレットもできるんじゃね? – 翻訳元ファイルの文字コードは Shift_JIS が良さげ。