Closed airobinnet closed 1 year ago
this fixes it
function autoresize() {
var textarea = $('#kw-target');
var width = textarea.width();
var content = (textarea.val() + "a").replace(/\\n/g, '<br>');
var div = $('<div>').css({
'position': 'absolute',
'top': '-99999px',
'border': '1px solid red',
'width': width,
'font-size': '15px',
'line-height': '20px',
'white-space': 'pre-wrap'
}).appendTo('body');
//The issue you're facing is because you're injecting the content into the DOM using the html() method,
//which causes the browser to parse and execute any script tags present in the content.
//To prevent this, you can create a text node instead of using the html() method.
// Create a text node with the content and append it to the div
var textNode = document.createTextNode(content);
div[0].appendChild(textNode);
var height = div.height();
var rows = Math.ceil(height / 20);
div.remove();
textarea.attr('rows', rows);
$("#article-wrapper").height(parseInt($(window).height()) - parseInt($("#fixed-block").height()) - parseInt($(".layout-header").height()) - 80);
}
even worse, try copy paste this into the demo:
<script> alert("This is very dangerous!"); </script>
thx for the function change! saved my day ... ;)
Weird behavior when you put this in the input:
if you have an api and you press enter it will keep on submitting page freezes, looks like it loads all those resources infinitly