【发布时间】:2019-08-13 00:25:18
【问题描述】:
除了主要部分之外,我的任务中的所有内容都已完成。我不知道如何让我的代码将我的 textarea 的内容作为 HTML 代码读取并在新窗口中显示结果。我什至不知道如何在内容出现时显示它们。
我没有保存我访问过的所有不同论坛的完整日志,但这里是我最近查看的几个论坛。
Open a new browser window/iframe and create new document from HTML in TEXTAREA?
https://www.codingforums.com/javascript-programming/174810-previewing-textarea-popup.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>
Wiki editor
</title>
</head>
<body>
<h1> Rachel </h1>
<script>
var previewOpen;
function preview() {
previewOpen = window.open("", "previewOpen", "width=500, height=600");
previewOpen.document.body.innerHTML = "HTML"; // Get the value of text area and run HTML code
}
function closePreview() {
previewOpen.close();
// function to close the preview
}
</script>
<p>Type your HTML code below:</p>
<textarea rows="20" cols="75">
</textarea>
<!-- textarea for submittance of code to be read and written -->
<br>
<span><input id="preview" type="submit" value="Preview" onClick="preview()">
<input id="closePreview" type="submit" value="Close Preview" onClick="closePreview()"></span> <!-- buttons with event handlers to read areatext and perform functions-->
</body>
</html>
【问题讨论】:
标签: javascript jquery html css textarea