-2

Try to redirect a page with javascript:

window.location.href = "/someFolder/page.aspx"

but the browser downloads the page instead of entering.

  • This question is very ambiguous. Can you redirect to other pages? If so then it's not a problem with the JavaScript - if I had to guess it would be that the server is serving the file with the incorrect file type. – James Monger Oct 14 '16 at 17:56
  • 1
    Did you try to just update the location manually to see if the page is diplayed or downloaded (second choice i think) – Arthur Oct 14 '16 at 17:58
  • @James didn't try to redirect to other pages. It must be this aspx. In some cases the browser redirects. In other cases it tries to download the aspx page – Raphael Ivo Oct 14 '16 at 17:59
  • @Arthur manually it works – Raphael Ivo Oct 14 '16 at 18:00
  • there's a number of questions related to this - see http://stackoverflow.com/questions/3846935/how-to-change-page-from-within-javascript As James said above, this looks like a problem with how the page is being served from the server. – Andrew Vogel Oct 14 '16 at 18:01
  • Are you sure you are testing the exact same URL manually and with the JS ? A good test is to use your JS to be redirected, cancel the download, copy this URL, and test on a new tab. – Arthur Oct 14 '16 at 18:06

2 Answers2

0

The page that redirects was .html. Changing it to .aspx resolved the problem, now it just redirects, it's not trying to download it.

-1

If you just want to open the page Use window.open("www.google.com") Explain what exactly you are looking at

Geeky
  • 7,420
  • 2
  • 24
  • 50