0

I am newbie to Phonegap so help me to getout from this issue.

In my application i have to redirect to List.html file while click on button1, I wrote code like this,

a href='#' onClick='test();' id="button"> button1

function test()

 {
       window.location="/home/swift-03/phonegapexamples/MySmartCity/www/List.html";

 }

But while running on emulator it showing file not found.whether i should use my local ip address to redirect to my List.html in local directory.

But when i am redirecting to www.google.com it is working fine.

function test()

 {
       window.location="www.google.com";

 }

This is redirecting to google page.

Please help me.thanks in advance

MAK
  • 390
  • 2
  • 8
  • 25
  • 1
    did you try accessing from the root? in this case `window.location="../home/swift-03/phonegapexamples/MySmartCity/www/List.html"` @Ashok kumar – Arty Sep 25 '14 at 10:50
  • thanks for reply. yes i tried from root,but button is not responding.do i need to use ip address of mine?@Arty – MAK Sep 25 '14 at 11:11

1 Answers1

1

Presuming that the original HTML that is showing button1 is in the same file directory, you would have to do:

HTML:

<body>
 <input type="button" href='#' onClick='test();' id="button" value="button1" ></input>
</body>

Javascript:

function test(){ /* Provideed master.html is in the same directory as the html that has button1*/ window.location=" ./master.html"; }

I hope this makes sense. If you want to access two directories above then you would have to use ../master.html but in this case, if the file is in the same directory you would have to do ./master.html

Arty
  • 819
  • 3
  • 13
  • 24
  • @Atry ,thankyou for replay, Both calling and called files are in same directory. but still it is showing file not found – MAK Sep 25 '14 at 11:22
  • maybe try `document.location = "./List.html";` @Ashokkumar – Arty Sep 25 '14 at 11:24
  • ,Sorry this was not working.on Browser it was running, but in emulator it was not running – MAK Sep 25 '14 at 11:34
  • You could check this [question](http://stackoverflow.com/questions/12036793/android-browser-facebook-redirect-does-not-always-trigger-intent-for-url), it might help. @Ashokkumar – Arty Sep 25 '14 at 11:39
  • thank you, I solved it. I did't given any path to html file.just mentioned file name without any path.it worked for me. Thank you for your support.@Arty – MAK Sep 25 '14 at 12:15