Facebook's status update input (well, contenteditable div) detects links.
When typing a link it waits until the spacebar is pressed before fetching the URL.
When pasting a link it fetches the URL instantly.
I can already parse the url after the spacebar is pressed...but I'm not sure about detecting when content is pasted.
Any solution would be awesome; a jQuery formatted solution will be BEST!
Modern day browsers support onpaste:
<!DOCTYPE html>
<html>
<head>
<title>onpaste event example</title>
</head>
<body>
<h1>Play with this editor!</h1>
<textarea id="editor" rows="3" cols="80">
Try pasting text into this area!
</textarea>
<script>
function log(txt) {
document.getElementById("log").appendChild(document.createTextNode(txt + "\n"));
}
function pasteIntercept(evt) {
log("Pasting!");
}
document.getElementById("editor").addEventListener("paste", pasteIntercept, false);
</script>
<h2>Log</h2>
<textarea rows="15" cols="80" id="log" readonly="true"></textarea>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With