I have input where I want to put copied text of user from another program like MS Word or from browser into suggestion box underneath it.
Is there any solution to do it at least in Chrome? These answers:
Is it possible to read the clipboard in Firefox, Safari and Chrome using Javascript? and
Get current clipboard content? and window.clipboardData.getData('Text')
don't work properly for me. Could someone give good solution?
Here my code ......
jQuery("#video-link").focus(function() {
var copied_obj = new ClipboardEvent('copy')
jQuery('.suggestion').html('').html('Copied text goes here')
})
jQuery('.suggestion').click(function() {
jQuery("#video-link").val(jQuery(this).text())
jQuery(this).fadeOut(1000)
})
.wrap {
padding: 0 100px;
margin: 0 auto;
height: 100px;
max-width: 1024px;
ma
}
#video-link {
background: #fff;
border: 2px solid #fff;
color: #333;
border: 1px solid #ccc;
height: 46px;
padding: 0 2%;
width: 96%;
font-weight: 600;
}
.suggestion {
color: #606775;
text-align: center;
font-weight: 700;
height: 30px;
display: block;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="wrap">
<input id="video-link" type="text" placeholder="Paste link here.." />
<div class="suggestion"></div>
</div>