Created
March 20, 2010 10:43
-
-
Save Griever/338606 to your computer and use it in GitHub Desktop.
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:document.addEventListener('paste', function(event){ | |
var obj = event.target; | |
if (!(obj instanceof HTMLTextAreaElement)) return; | |
var firstText = obj.value.substr(0, obj.selectionStart); | |
var latterText = obj.value.substr(obj.selectionEnd); | |
obj.addEventListener('input', function(evt){ | |
evt.currentTarget.removeEventListener(evt.type, arguments.callee, false); | |
var pastedText = obj.value.substring(firstText.length, obj.value.length - latterText.length); | |
pastedText = pastedText.replace(/javascript:/g, ''); | |
obj.value = firstText + pastedText + latterText; | |
}, false); | |
},false) | |
/* | |
ペースト時に「ペーストされた部分」のみ特定の文字を置き換えるスクリプト。 | |
setTimeout を使わないのは気分 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment