Just add the next code:
$('html,body').animate({ scrollTop: _top }, 1000, 'swing');
Reference: http://api.jquery.com/animate/
Thursday, October 5, 2017
CLEditor, paste as plain text
CLEditor is an open source jQuery plug-in which provides a lightweight, full featured, cross browser, extensible, WYSIWYG HTML editor that can be easily added into any web site.
In order to prevent users to paste content with formatted text, and instead, get only its text the following chunk of cross-browser code:
var _$ta = $('textarea.richText').cleditor({
// options
}),
_clEdit = _$ta.cleditor()[0];
$(_clEdit.$frame[0].contentWindow.document)
.on('rightclick', function (e) {
e.preventDefault();
})
.on('paste', function (e) { // Paste as plain text
var content = '';
e.preventDefault();
if (e.originalEvent.clipboardData) {
content = (e.originalEvent
|| e).clipboardData.getData('text/plain');
}
else if (window.clipboardData) {
content = window.clipboardData.getData('Text');
}
content = content.replace(/\n/g, "<br />");
_clEdit.execCommand('inserthtml', content);
});
In order to prevent users to paste content with formatted text, and instead, get only its text the following chunk of cross-browser code:
var _$ta = $('textarea.richText').cleditor({
// options
}),
_clEdit = _$ta.cleditor()[0];
$(_clEdit.$frame[0].contentWindow.document)
.on('rightclick', function (e) {
e.preventDefault();
})
.on('paste', function (e) { // Paste as plain text
var content = '';
e.preventDefault();
if (e.originalEvent.clipboardData) {
content = (e.originalEvent
|| e).clipboardData.getData('text/plain');
}
else if (window.clipboardData) {
content = window.clipboardData.getData('Text');
}
content = content.replace(/\n/g, "<br />");
_clEdit.execCommand('inserthtml', content);
});
Etiquetes de comentaris:
jquery,
jQuery Plugins
Subscribe to:
Posts (Atom)