Firdaus Archive

Blog pribadi untuk curhat, share tentang script, software, kuliah, project IT dan seputar IT.

Displaying URL parameter values as text in an element on webpage

Tidak ada komentar

 source https://stackoverflow.com/questions/71727647/displaying-url-parameter-values-as-text-in-an-element-on-webpage-question-from


<!-- example url https://exampleurl.com/?birthdate=22091977&pdflink=yourlink123.pdf-->


<html>

    <body>

        <span id="birthdate"></span>

</br>

<span id="pdflink"></span>

    </body>

</html>


<script>

    const queryString = window.location.search;

    const urlParams = new URLSearchParams(queryString);

    const birthdate = urlParams.get('birthdate');

    const pdflink = urlParams.get('pdflink');

    document.getElementById("birthdate").innerHTML = birthdate;

document.getElementById("pdflink").innerHTML = pdflink;

</script>