Dav*_*och 6 javascript jquery facebook
Facebook的状态更新输入(嗯,contenteditable div)检测链接.
键入链接时,它会等到按下空格键后才能获取URL.
粘贴链接时,它会立即获取URL.
我可以在按下空格键后解析URL ...但我不确定何时检测内容被粘贴.
任何解决方案都会很棒; 一个jQuery格式的解决方案将是最好的!
epa*_*llo 10
现代浏览器支持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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2699 次 |
| 最近记录: |