On my site, users can paste text (in this case, url) into the input field. I would like to capture the meaning of the text that was inserted using jQuery. I have this to work in FF using the code below, but it does not work in IE (I don't think IE supports the "paste" event).
Does anyone know how to make this work in all modern browsers? I found several other answers to this on SO, but most of them are only FF, and none of them offer a complete solution.
Here is the code that I still have:
$("input.url").live('paste', function(event) { var _this = this; // Short pause to wait for paste to complete setTimeout( function() { var text = $(_this).val(); $(".display").html(text); }, 100); });
JSFiddle: http://jsfiddle.net/TZWsB/1/
jQuery live- - IE; :
$(document).ready(function() { $(".url").bind('paste', function(event) { var _this = this; // Short pause to wait for paste to complete setTimeout( function() { var text = $(_this).val(); $(".display").html(text); }, 100); }); });
Fiddle: http://jsfiddle.net/Trg9F/
change, paste. change , paste , ; , , , , , IME ..
change
paste
change , , . , input... , HTML5, ( : IE < 9). , :
input
$('.url').bind('input change paste keyup mouseup',function(e){ ... });
, , input, , setInterval.
setInterval
$('input').on('paste', function(e) { // common browser -> e.originalEvent.clipboardData // uncommon browser -> window.clipboardData var clipboardData = e.clipboardData || e.originalEvent.clipboardData || window.clipboardData; var pastedData = clipboardData.getData('text'); });
e.originalEvent.clipboardData.getData('text'); ;
$("input").on("paste", function(e) { var pastedData = e.originalEvent.clipboardData.getData('text'); // ... now do with pastedData whatever you like ... });
, -, .
, onblur. , c/p , script , . , c/p, .
onblur
Source: https://habr.com/ru/post/1544371/More articles:How to change the Levenshtein algorithm, find out if he inserted, deleted or replaced a character? - pythonHow is it normal for sendmail to send emails from any domain? - emailC # Add array elements to a list in a loop - arrays"Do not join" in R - mergejQuery - when changing text during user input or insertion - jqueryGCC inline asm: direct memory link restriction - cCheck to see if a string is letters + spaces ONLY? - javaHow to look at the imported OpenCV code? (specifically python cv2) - pythonCount to infinity and beyond, not ready - c #can't use kendo ui with cassette sets in asp.net mvc - asp.net-mvcAll Articles