Reputation: 5
I have searched so much for this. How do I make JS make a link that goes something along the lines of example.com/index.php#number
?
Example of what i mean - https://gyazo.com/428ea0c819d340a699a328baaf4c1c1f
Upvotes: 0
Views: 85
Reputation: 500
Lets say that you have your base address, "http://www.example.com/index.php", what you want to do is to add a new part to the url
const base = "http://www.example.com/index.php"
let number = 42
location.href = base + "#" + number
which will redirect you to "http://www.example.com/index.php#42"
Upvotes: 1
Reputation: 71
I am not really sure what are you trying to achieve here but I hope this helps.
let a = document.createElement('a');
let url_link_title = document.createTextNode("Your Title Here.");
a.appendChild(url_link_title);
a.title = "Your Title Here";
a.href = "http://yoursampleaddress.com";
document.body.appendChild(a);
Upvotes: 1