Hacker News new | ask | show | jobs
by gpnt 849 days ago
Well, you are using javascript anyway so here it is a 163 bytes solution without the back button problem and iframe hack:

<script>onclick=async e=>{x=e.target.dataset.x;if(x){e.preventDefault();document.querySelector(x).innerHTML=await fetch(e.target.href).then(r=>r.text())}}</script>

<a href="/somepage" data-x="#lib">Hi</a>

<div id="lib"></div>

doesn't works with form though.

1 comments

You can make it work with forms by using onsubmit and e.target.action