JavaScript gets the method url in the page base tag
- 2020-05-26 07:44:35
- OfStack
The example in this article shows how JavaScript gets url in the page base tag. Share with you for your reference. The details are as follows:
If the base tag is defined in the web page, we can get the url address of base from the js code
<!DOCTYPE html>
<html>
<head>
<base id="htmldom" href="https://www.ofstack.com/">
</head>
<body>
<p>Base URL is:
<script>
document.write(document.getElementById("htmldom").href);
</script>
</p>
</body>
</html>
The results are as follows:
Base URL is:https://www.ofstack.com/
I hope this article is helpful for you to design javascript program.