写成html页面var xhr = new XMLHttpRequest;xhronreadystatechange = function if xhrreadyState === 4 if xhrstatus === 200 var textareaContent = xhrresponseText; consolelogte
<!DOCTYPE html>
<html>
<head>
<title>Fetch Textarea Content</title>
</head>
<body>
<button onclick="fetchTextareaContent()">Fetch Textarea Content</button>
<textarea id="myTextarea"></textarea>
<script>
function fetchTextareaContent() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var textareaContent = xhr.responseText;
document.getElementById("myTextarea").value = textareaContent;
} else {
console.error('Error: ' + xhr.status);
}
}
};
xhr.open('GET', 'http://example.com/textarea-id');
xhr.send();
}
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/9dG 著作权归作者所有。请勿转载和采集!