Is it possible to get the domain name of page as meta title via javascript in html? Can somebody please paste the code?
Asked
Active
Viewed 114 times
1 Answers
0
You can use appendChild
to add elements to your head
.
I have no idea how well this will fare with search bots.
This site is not for asking others to program for you, but I guess it's hard to get started if you don't know where to start, and it didn't take any time for me to answer.
<html>
<head>
</head>
<body>
</body>
<script>
const createTitleTag = (title) => {
let headEl = document.querySelector('head');
let titleEl = document.createElement('title');
titleEl.innerText = title;
headEl.appendChild(titleEl);
}
createTitleTag(location.host);
</script>
</html>

Rickard Elimää
- 7,107
- 3
- 14
- 30