Hi all,
I need help to fill text in modal like this site, here the example:
When I add text in URL → ?tamu=BLOCSAPP
The modal will show with BLOCSAPP text.
For other example, the text in URL is bootstrap4
The modal will show with bootstrap4 text.
How to make site like this? I see the view source/source code but not get any clue.
Thank you.
Hey @aquaria
You can do this by placing a script like this in your page footer.
(this works if your parram is ?text=hello )
<script>
window.onload = function() {
var target = document.getElementById("my-text")
var url = window.location.search;
var urlParams = new URLSearchParams(url);
var newText = urlParams.get('text')
target.innerText = newText;
}
</script>
All you need to do is give the text you want to change an ID. You can set the ID on the second line, change my-text
to something that suites you.
You can also change the name of the parameter by changing text
on the 5th line.
1 Like