選択範囲を取得
by
Cside
2012-03-08 [2012/03/08 14:48:05]
選択範囲を取得
@@ -4,9 +4,9 @@
* @include http://*
* @license MIT License
- */
+*/
-window.onload = funciton() {
+(function(){
var selection
= window.getSelection ? window.getSelection()
: document.getSelection ? document.getSelection()
@@ -14,4 +14,4 @@
: 0
;
console.log(selection);
-}
+})();
/*
* @title 選択範囲を取得
* @description 選択範囲を取得
* @include http://*
* @license MIT License
*/
(function(){
var selection
= window.getSelection ? window.getSelection()
: document.getSelection ? document.getSelection()
: document.selection ? document.selection.createRange().text
: 0
;
console.log(selection);
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。