Skip to content
Advertisement

path broke when uploaded to server (link from js to html)

I programmed a webside and a bunch of it broke when I uploaded it onto the server (until now I only ever programmed locally and not very often at that) I fixed nearly everything but the links between pages.

What works is the “a” element in html to link but most of my pages are linking to oneanother in their js code.

I put all files on the same directory, after trying some path variants (I tried the URL too), so there would be no path and it still didn’t work. I have to assume that “window.location.pathname = “result.html” is not the right way.

In Vsc, with the live server, it works, but not on the real one

Advertisement

Answer

After reading documentation it says:

The pathname property of the Location […] containing the path of the URL for the location, which will be the empty string if there is no path.

So it just gives you path, and it not intended for redirection. What you are looking for is certainly window.location.replace which documentation can be found here

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement