0

I have created 2 static html pages locally, demo1.html and demo2.html.

I need to redirect from one page to another pag. Initially I opened my demo1.html page (url is file:///D:/app/demo1.html).

Now on clicking a button in this page I want to redirect to demo2.html

I tried:

$( "#submit" ).click(function() {
    window.location.href = "/demo2.html";
});

but it did not work. What changes I need to make it to work?

Lucky
  • 16,787
  • 19
  • 117
  • 151
monda
  • 3,809
  • 15
  • 60
  • 84

2 Answers2

3

Drop the / at the begining of your new url.

If you are loading from a file like you said, writing "/demo2.html" will map to file:///d:/demo2.html

If you write

 $( "#submit" ).click(function() {
     window.location.href = "demo2.html";
 });

This will map to the same folder where you started your app, that is file:///D:/app/demo2.html

devconcept
  • 3,665
  • 1
  • 26
  • 40
  • Did not work, it just adds "?" to th url , no redirection happens – monda May 18 '15 at 17:00
  • I just tested the code an it works. If is not working for you is because you are not showing the full example. I recommend you that you post the demo1.html code (Maybe you are using another framework????) – devconcept May 18 '15 at 17:05
0

Try this

 $('#submit').click(function() {
     window.location = '/demo2.html';
 };
Touhid Alam
  • 343
  • 1
  • 5