Created
January 16, 2012 09:54
-
-
Save kits/1620049 to your computer and use it in GitHub Desktop.
全文または選択範囲をマルチカラム化(Firefox用)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){%0A%09var%20sel%20=%20window.getSelection(),%0A%09%09body%20=%20document.body,%0A%09%09src;%0A%0A%09if%20(sel.isCollapsed)%20{%0A%09%09src%20=%20body.innerHTML;%0A%09}%0A%09else%20{%0A%09%09var%20frag%20=%20sel.getRangeAt(0).cloneContents();%0A%09%09var%20div%20=%20document.createElement('div');%0A%09%09div.appendChild(frag);%0A%09%09src%20=%20div.innerHTML;%0A%09}%0A%0A%09/*%20other%20window%20*/%0A%09//var%20win%20=%20window.open('',%20'_blank');%0A%09/*%20this%20widow%20*/%0A%09var%20win%20=%20window;%0A%0A%09var%20doc%20=%20win.document;%0A%09doc.open();%0A%09doc.write('<body>',%20src,%20'</body>');%0A%09doc.close();%0A%0A%09var%20bstyle%20=%20doc.body.style;%0A%09bstyle.MozColumnWidth%20=%20'25em';%0A})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var sel = window.getSelection(), | |
body = document.body, | |
src; | |
if (sel.isCollapsed) { | |
src = body.innerHTML; | |
} | |
else { | |
var frag = sel.getRangeAt(0).cloneContents(); | |
var div = document.createElement('div'); | |
div.appendChild(frag); | |
src = div.innerHTML; | |
} | |
/* other window */ | |
//var win = window.open('', '_blank'); | |
/* this widow */ | |
var win = window; | |
var doc = win.document; | |
doc.open(); | |
doc.write('<body>', src, '</body>'); | |
doc.close(); | |
var bstyle = doc.body.style; | |
bstyle.MozColumnWidth = '25em'; | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
このスクリプトは以下の記事にヒントを得て書きました。
http://jintrick.net/stream/2011/winter.html#B29NS1RN91Y-2012-01-13-Fri
webkitに対応したスクリプトが以下にあります。
http://jintrick.net/stream/2011/winter.html#HTR3SC0AHSL-2012-01-18-Wed