I have two html files, main.html and iframe.html, and I need to display iframe.html inside main.html as an iframe and main.html is the page I want to stay on:
main.html
<body>
<a href="iframe.html#goto" target="tableB" class="btn btn-secondary">Find</a>
<table class="table">
<thead>
<tr>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Citizen</td>
</tr>
<!-- 100 items more -->
</tbody>
</table>
<iframe name="tableB" src="iframe.html" width="100%" height="1000"></iframe>
</body>
iframe.html
<body>
<table class="table">
<thead>
<tr>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>...</td>
<td>...</td>
</tr>
<!-- 50 items more -->
<tr id="goto">
<td>Alice</td>
<td>Smith</td>
</tr>
<!-- 50 items more -->
</tbody>
</table>
</body>
what I want to achieve is, when I click the <a> link, the current page should jump to the the iframe’s Alice Smith record, and I don’t want to open another page for indexB.html to display, I just want to display it in main.html and do the jump in main.html
But it doesn’t work when I click the link button, it doesn’t jump to the correct section which is the iframe’s Alice Smith record, where did I do wrong? I did exactly the same in Need help with iframe and jumping to topic