0

I'm having problem in redirecting at JS. Here's the situation: the current directory of the html code is : http://localhost:7927/MyWeb/Catch%20the%20bird%20game/GAME1.html

I want to change the directory to

'http://localhost:7927/MyWeb/games.htm'

I tried using window.location("games.htm"); but it will redirect to that directory:

http://localhost:7927/MyWeb/Catch%20the%20bird%20game/GAME1.html/games.htm

What's the solution? Thanks.

idish
  • 3,190
  • 12
  • 53
  • 85

4 Answers4

1

You can try:

window.location("../games.htm");

or:

window.location("/MyWeb/games.htm");
primavera133
  • 1,284
  • 1
  • 15
  • 24
  • The / infront of the file name tells the script to go to the root of the webserver and then find the document. Whereas if you don't add the / it'll search in the current folder :) That's what went wrong.. – f2lollpll May 28 '12 at 08:28
0

You should use

window.location.href = "/myweb/games.htm"
Iridio
  • 9,213
  • 4
  • 49
  • 71
0

use

window.location = 'http://localhost:7927/MyWeb/games.htm';

or just this

window.location = '/MyWeb/games.htm';
Uttara
  • 2,496
  • 3
  • 24
  • 35
0

I normally use

window.location.href = ...

or

window.location.replace(...);

Also check out this SO post.

Community
  • 1
  • 1
Juri
  • 32,424
  • 20
  • 102
  • 136