MAK
MAK

Reputation: 390

Rediection not working from file system in emulator

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

Upvotes: 0

Views: 40

Answers (1)

Arty
Arty

Reputation: 857

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

Upvotes: 1

Related Questions