javascript - href not working, how to redirect to a specific page in PhoneGap? - Stack Overflow

In Html5 I go to a specific page in the following manner:window.location.href = "http:localhost:

In Html5 I go to a specific page in the following manner:

window.location.href = "http://localhost:XXXX/MyPageName.html";

The href by clicking on the button does not work!! I have no idea why, it's the only way I could solve this problem.

When I run the html5 application using the PhoneGap, the links do not work (obviously, since there is no localhost to application)

How can I solve this problem?

In Html5 I go to a specific page in the following manner:

window.location.href = "http://localhost:XXXX/MyPageName.html";

The href by clicking on the button does not work!! I have no idea why, it's the only way I could solve this problem.

When I run the html5 application using the PhoneGap, the links do not work (obviously, since there is no localhost to application)

How can I solve this problem?

Share Improve this question asked Dec 3, 2012 at 13:12 Hodaya ShalomHodaya Shalom 4,42713 gold badges60 silver badges115 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

First, your links might not work, because cordova/phonegap blocks all external URLs by default. To fix this, read my answer here.

Second, Phonegap does not open a webserver, so http://localhost is not correct. When you want to have an internal link, use something like <a href="/mydir/mypage.html">linkText</a>.

You will solve your problems using something like this:

<script>
    //action go to pageOther
    $.mobile.changePage('#pageOther','slide');
</script>
<body>
    <div data-role="page" id="pageHome">
        //Your html
    </div>
    <div data-role="page" id="pageOther">
        //Your html
    </div>
</body>

See more info: http://jquerymobile./demos/1.2.0/docs/pages/page-anatomy.html

Phonegap suggest not having multiple pages. You should have "content" section in one page and then through the dynamic linking (using #page1 where page1 is the content area id)

Example.

all in same html page (index.html)

<div data-role="page" id="page0">
<a data-role="button" data-transition="slide" href="#page1">Page 1</a>
<div>

<div data-role="page" id="page1">

<div>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744316396a4568204.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信