Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I make JavaScript generate a new link?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading