Home » jQuery 外掛

[jQ]Wordsmith 1.01

範例 1
沒錯!只要 300 元就能獲得我們團隊完整的協助,讓效果能迅速的整合到您的網站,並保證瀏覽器的相容性。
立刻申請!

wordsmith-0

Wordsmith 可以將使用者在網頁中所選取的字傳給指定的程式來進行搭配使用,像是把單字或句子傳給 Google 翻譯就查看翻譯結果等等。

套件名稱:Wordsmith
套件網址:1.01
作者網站:http://getwordsmith.co/
套件網址:N/A
發佈日期:2012-08-15
檔案大小:2 KB
檔案下載:wordsmith.min.js

參數選項說明:

檢視原始碼 JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
maxWordLength(選填)
描述: 允許最多能選取幾個字元, 超過限制將不會顯示圖示
預設值: 18
 
popupWidth(選填)
描述: 彈出視窗的寬度
預設值: 600
 
popupHeight(選填)
描述: 彈出視窗的高度
預設值: 400
 
lookupImage(選填)
描述: 當選取字後要出現讓使用者點擊的圖示
預設值: 'http://getwordsmith.co/images/Question_Mark.png'
 
lookupMessage(選填)
描述: 當使用者把滑鼠移到圖示時要顯示的文字訊息
預設值: 'Lookup definition'
 
lookupUrl(選填)
描述: 用來進行翻譯查詢的程式路徑;其中的 {word} 會自動替換為使用者所選取的字
預設值: 'http://define.getwordsmith.co/{word}'

方法說明:

檢視原始碼 JavaScript
1
2
// 將在指定元素中被使用者選取的字進行查詢
$(selector).wordsmith(options);

使用範例:

檢視原始碼 JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="wordsmith.min.js"></script>
<style type="text/css">
	#wordsmith-lookup img {
		border: none;
	}
</style>
<script type="text/javascript">
	$(function(){
		// 使用 google 來進行翻譯, 最多允許選取 600 個字元
		$('body').wordsmith({
			maxWordLength: 600,
			popupWidth: 800,
			popupHeight: 300,
			lookupImage: 'images/Question_Mark.png',
			lookupMessage: '查詢這單字的解釋',
			lookupUrl: 'http://translate.google.com.tw/#auto/zh-TW/{word}'
		});
	});
</script>
 
<body>
	<h3>What is jQuery?</h3>
	<p>jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.</p>
</body>
範例 1

檔案描述
基本的範例檔案(免空) 開始下載
基本的範例檔案 會員限定

發表迴響