我最近在尝试用HTML创建查询(提问)页面。我有一个使用get方法的表单,我知道这是一种跨页面发送数据并使用JavaScript的方法。是否可以在链接页面内创建带有表单数据的链接?
// Get the contents of //
var inputBox = document.getElementById('QueryTitle');
// Use the onkeyup to get the values of user input //
inputBox.onkeyup = function(){
// MAKE NO BAD TAGS APPEAR IN QUESTIONS //
const goodTags = ['<b>' , '</b>' , '<i>' , '</i>' , '<br>' , '</br>']
var tag = inputBox.value.match(/<.+>/)
if (tag && !goodTags.includes(tag[0])) { inputBox.value = inputBox.value.replace(tag[0], '') };
document.getElementById('QueryTitleOutput').innerHTML = inputBox.value;
}
// Get the questions contents, normally in the textarea of the page //
var textarea = document.getElementById('QueryInput');
// Use the onkeyup to get the values of user input //
textarea.onkeyup = function(){
// MAKE NO BAD TAGS APPEAR IN QUESTIONS //
const goodTags = ['<b>' , '</b>' , '<i>' , '</i>' , '<br>' , '</br>']
var tag = textarea.value.match(/<.+>/)
if (tag && !goodTags.includes(tag[0])) { textarea.value = textarea.value.replace(tag[0], '') };
document.getElementById('QueryOutputFrame').innerHTML = textarea.value;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- This the form that uses the get method to show data in the URL -->
<form action="Get Text As A Link.html" method="get">
<input type="text" id="QueryTitle" name="QueryTitle" placeholder="Ask Something">
<br>
<br>
<!-- this is the main query textarea !-->
<textarea id="QueryInput" name="QueryInput" style="width: 780px; height: 200px;">
</textarea>
<!-- Widgets for the textarea !-->
<br>
<div id="QueryTitleOutput">
</div>
<br>
<br>
<div id="QueryOutputFrame" style="width: 90%; height: 10em;">
</div>
</center>
<br>
<br>
<br>
<br>
<br>
<center>
<input type="submit" id="final" value="Submit Question" class="unhidden" class="btn btn-submit" onclick="location.href = 'Get Text As A Link.html';" onSubmit="">
</center>
</form>
&#13;