I have a webpage dat greets you with welcome {name}. But the {name} has to be replaced with a name/word at the end of the url. The best I would find is after the # but something else is welcome.
I have tried to look up the different parts and put them together. But I don’t know much about Javascript and it display the script that pulled the url instead of the output of that script.
2
Answers
var hash = location.hash.substr(1);
gets the value after the#
Feels like this might have been asked before.
You can use JavaScript to extract the word and manipulate the DOM to update the label’s content.
In this example,
window.location.hash
retrieves the portion of the URL after the # symbol. The substring(1) method is used to remove the # symbol from the string, leaving only the word behind it.Then, the textContent property of the label element is updated with the extracted word, making it display between the label tags.
Make sure to place this JavaScript code after the label element in your HTML file.