it seems impossible to achieve without storing somewhere, but I have a unique idea that you could experiment with.
Here is the revised code where I've added 2 new functions: one that changes the URL when typing in the search box (since this might not function on jsfiddle, I've provided an example link on my domain for testing purposes), and the second function retrieves the URL if it exists in the search box.
https://i.sstatic.net/4qj6R.jpg
<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e4888b8085978ca4d0cad5d3cad5d5">[email protected]</a>/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js"></script>
<div class="input-wrap">
<label>
Search
<input onkeydown="inputchange(this)" id="myInput" type="text" required placeholder="Search Titles" />
</label>
</div>
<div class="hintsWrap">
<p id="noMatches"></p>
<p class="hints">
Hints: type "Title1", "Title2", "Title3"...
</p>
</div>
<br />
<br />
<br />
<table id="myTable" style="width: 100%" class="style1">
<tr>
<td>
<br />
<br />
<table style="width: 100%">
<tr>
<td>
<table style="width: 100%">
<tr>
<th class="style1">Type</th>
<td>type1</td>
</tr>
<tr>
<th class="style1">Title</th>
<td>title1</td>
</tr>
<tr>
<th class="style1">Description</th>
<td>description1</td>
</tr>
<tr>
<th class="style1">Date</th>
<td>date1</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<br />
<table style="width: 100%">
<tr>
<th class="style1">Type</th>
<td>type2</td>
</tr>
<tr>
<th class="style1">Title</th>
<td>title2</td>
</tr>
<tr>
<th class="style1">Description</th>
<td>description2</td>
</tr>
<tr>
<th class="style1">Date</th>
<td>date2</td>
</tr>
</table>
<br />
<br />
<table style="width: 100%">
<tr>
<th class="style1">Type</th>
<td>type3</td>
</tr>
<tr>
<th class="style1">Title</th>
<td>title3</td>
</tr>
<tr>
<th class="style1">Description</th>
<td>description3</td>
</tr>
<tr>
<th class="style1">Date</th>
<td>date3</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
</td>
</tr>
</table>
</html>
<script>
var input, table, rows, noMatches, tr, markInstance;
$(document).ready(function init() {
input1 = document.getElementById('myInput');
noMatches = document.getElementById('noMatches');
table = document.querySelectorAll('#myTable table tr:first-child');
rows = document.querySelectorAll('#myTable table tr');
markInstance = new Mark(table);
input1.addEventListener('input', ContactsearchFX, true);
var q = window.location.href.split("=");
if(q[1]){
input1.value=q[1];
const event = new MouseEvent('input', {
view: window,
bubbles: true,
cancelable: true
});
const cancelled = !input1.dispatchEvent(event);
}
});
function ContactsearchFX() {
resetContent();
markInstance.unmark({
done: highlightMatches
});
}
function resetContent() {
$('.noMatchErrorText').remove();
rows.forEach(function (row) {
$(row).removeClass('show');
});
}
function highlightMatches() {
markInstance.mark(input1.value, {
each: showRow,
noMatch: onNoMatches,
exclude: ['.nonsearch']
})
}
function showRow(element) {
$(element).parents('tr').addClass('show');
$(element).parents('tr').siblings('tr').addClass('show');
}
function onNoMatches(text) {
$('#myInput').after('<p class="noMatchErrorText">No records match: "' + text + '"</p>');
}
/* Prevents Return/Enter key from doing anything */
$(document).on('submit', 'form', function (e) {
if ($(e.delegateTarget.activeElement).not('input, textarea').length == 0) {
e.preventDefault();
return false;
}
});
function inputchange(x) {
const addTourl = x.value;
console.log("addTourl", addTourl);
history.pushState("", "Title", "?q="+addTourl);
}
</script>
<style>
.input-wrap {
margin-bottom: 12px;
}
#myInput:invalid~.hints {
display: block;
}
#noMatches:empty,
#noMatches:empty+.hints {
display: none;
}
.style1 tr {
display: none;
}
.style1 .show {
display: table-row;
}
#myTable table tr:first-child td mark {
background: orange;
font-weight: bold;
color: black;
}
mark {
background: initial;
}
.style1 {
text-align: left;
}
</style>
new version:
<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js"></script>
<div class="input-wrap">
<label>
Search
<input oninput="inputchange(this)" id="myInput" type="text" required placeholder="Search Titles" />
</label>
</div>
<div class="hintsWrap">
<p id="noMatches"></p>
<p class="hints">
Hints: type "Title1", "Title2", "Title3"...
</p>
</div>
<br />
<br />
<br />
<table id="myTable" style="width: 100%" class="style1">
<tr>
<td>
<br />
<br />
<table style="width: 100%">
<tr>
<td>
<table style="width: 100%">
<tr>
<th class="style1">Type</th>
<td>type1</td>
</tr>
<tr>
<th class="style1">Title</th>
<td>title1</td>
</tr>
<tr>
<th class="style1">Description</th>
<td>description1</td>
</tr>
<tr>
<th class="style1">Date</th>
<td>date1</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<br />
<table style="width: 100%">
<tr>
<th class="style1">Type</th>
<td>type2</td>
</tr>
<tr>
<th class="style1">Title</th>
<td>title2</td>
</tr>
<tr>
<th class="style1">Description</th>
<td>description2</td>
</tr>
<tr>
<th class="style1">Date</th>
<td>date2</td>
</tr>
</table>
<br />
<br />
<table style="width: 100%">
<tr>
<th class="style1">Type</th>
<td>type3</td>
</tr>
<tr>
<th class="style1">Title</th>
<td>title3</td>
</tr>
<tr>
<th class="style1">Description</th>
<td>description3</td>
</tr>
<tr>
<th class="style1">Date</th>
<td>date3</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
</td>
</tr>
</table>
</html>
<script>
var input, table, rows, noMatches, tr, markInstance;
$(document).ready(function init() {
input1 = document.getElementById('myInput');
noMatches = document.getElementById('noMatches');
table = document.querySelectorAll('#myTable table tr:first-child');
rows = document.querySelectorAll('#myTable table tr');
markInstance = new Mark(table);
input1.addEventListener('input', ContactsearchFX, true);
var q = window.location.href.split("=");
if(q[1]){
input1.value=q[1];
const event = new MouseEvent('input', {
view: window,
bubbles: true,
cancelable: true
});
const cancelled = !input1.dispatchEvent(event);
}
});
function ContactsearchFX() {
resetContent();
markInstance.unmark({
done: highlightMatches
});
}
function resetContent() {
$('.noMatchErrorText').remove();
rows.forEach(function (row) {
$(row).removeClass('show');
});
}
function highlightMatches() {
markInstance.mark(input1.value, {
each: showRow,
noMatch: onNoMatches,
exclude: ['.nonsearch']
})
}
function showRow(element) {
$(element).parents('tr').addClass('show');
$(element).parents('tr').siblings('tr').addClass('show');
}
function onNoMatches(text) {
$('#myInput').after('<p class="noMatchErrorText">No records match: "' + text + '"</p>');
}
/* Prevents Return/Enter key from doing anything */
$(document).on('submit', 'form', function (e) {
if ($(e.delegateTarget.activeElement).not('input, textarea').length == 0) {
e.preventDefault();
return false;
}
});
function inputchange(x) {
const addTourl = x.value;
console.log("addTourl", addTourl);
history.pushState("", "Title", "?q="+addTourl);
}
</script>
<style>
.input-wrap {
margin-bottom: 12px;
}
#myInput:invalid~.hints {
display: block;
}
#noMatches:empty,
#noMatches:empty+.hints {
display: none;
}
.style1 tr {
display: none;
}
.style1 .show {
display: table-row;
}
#myTable table tr:first-child td mark {
background: orange;
font-weight: bold;
color: black;
}
mark {
background: initial;
}
.style1 {
text-align: left;
}
</style>