简体   繁体   English

Windows Phone 8上使用HTML / JavaScript / Apache Cordova的页面导航

[英]Page Navigation on Windows Phone 8 using HTML/JavaScript/Apache Cordova

I have some problems with page navigation using Windows Phone 8 with Apache Cordova 3.0. 我在使用Windows Phone 8和Apache Cordova 3.0进行页面导航时遇到一些问题。
I tried different ways to solve this problems but it still does not work. 我尝试了不同的方法来解决此问题,但仍然无法正常工作。

At first i tried to use forms to navigate to another page. 起初,我尝试使用表单导航到另一个页面。

<form action="CreateUser.html" method="get">
        <input class="buttons"  name="btnCreateUser" type="submit" value="Create User" />
</form>

When i click on the button the page can not be found. 当我单击按钮时,找不到页面。 The CreateUser.html page is in the same directory. CreateUser.html页面位于同一目录中。 If i use a Browser (Chrome/IE) it works. 如果我使用浏览器(Chrome / IE),则可以使用。

When i change the action to http://www.google.com both options (Browser and Phone) work. 当我将操作更改为http://www.google.com时,两个选项(浏览器和电话)均起作用。

I also tried to navigate to another page by using JavaScript. 我还尝试使用JavaScript导航到另一个页面。 Here is my code: 这是我的代码:

function get(httpUrl) {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", httpUrl, true);
    xmlHttp.send(null);
    return xmlHttp.responseText;
}

Now i use onclick="get("CreateUser")" event of the button but there is no reaction. 现在,我使用按钮的onclick =“ get(” CreateUser“)”事件,但没有任何反应。 Both in the browser and on the mobile device. 在浏览器和移动设备上。

The only thing that worked for me is the window.location feature. 对我唯一起作用的是window.location功能。 But it seems that i can't transform informations on the next page with that way. 但似乎我无法以这种方式转换下一页上的信息。

Is there any opportuinity to navigate between those two pages and transfer some information? 在这两个页面之间导航并传递一些信息是否有任何机会?
Or did i just something wrong in my code? 还是我的代码有问题?

"The CreateUser.html page" if i'm correct you are using AJAX to read file (page) contents and paste them in HTML? “ CreateUser.html页面”(如果我是正确的话)是您使用AJAX读取文件(页面)内容并将其粘贴到HTML中?

If yes, then read this: 如果是,请阅读以下内容:

2.1. 2.1。 Cross-domain problem 跨域问题

Before making AJAX request you must allow cross-domain requests and core support, by setting: 在发出AJAX请求之前,您必须通过设置以下内容来允许跨域请求和核心支持:

jQuery.support.cors = true;
$.mobile.allowCrossDomainPages = true;

Those must be set in a specific-phonegap function “DeviceReady”, example: 这些必须在特定的电话间隙功能“ DeviceReady”中设置,例如:

document.addEventListener('deviceready', function () {
            jQuery.support.cors = true;
            $.mobile.allowCrossDomainPages = true;
            $.ajax({
                url: "www/about.txt",
                dataType: 'text'
            }).done(function (result) {
                    alert(result);
                });
            });

2.2. 2.2。 url 网址

Making Windows Phone 8 oriented application, in AJAX request you MUST specify full path to resource, example: url: "www/about.txt", 制作面向Windows Phone 8的应用程序时,必须在AJAX请求中指定资源的完整路径,例如:url:“ www / about.txt”,

Making Windows Phone 8 oriented application, in AJAX request you MUST NOT specify full path to resource, example: url: "about.txt", 制作面向Windows Phone 8的应用程序时,不得在AJAX请求中指定资源的完整路径,例如:url:“ about.txt”,

2.3. 2.3。 Source File extensions 源文件扩展名

Be careful using unknown extension files, like template extension *.tpl or similar. 请小心使用未知的扩展名文件,例如模板扩展名* .tpl或类似文件。 Sometimes AJAX doesn't like them, I suggest using simple *.txt and *.html extensions. 有时AJAX不喜欢它们,我建议使用简单的* .txt和* .html扩展名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么将JavaScript称为“ alert();” 功能为Apache Cordova开发时,Windows Phone中的应用程序崩溃了吗? - Why does calling the JavaScript 'alert();' function crash the app in Windows Phone when developing for Apache Cordova? 用于Apache Cordova的JavaScript代码在模拟器Ripple上运行,但不在Live Windows Phone设备中运行(L 535) - javascript code for apache Cordova working on simulator Ripple but not in Live windows phone Device (L 535) Windows Phone 7 Web App中的页面导航 - Page Navigation in Windows phone 7 Web App 在Apache Cordova Windows App中使用聚合物 - Using polymer for apache cordova windows app 在HTML / Javascript中创建页面导航 - Create page navigation in HTML/Javascript 在Cordova / Phonegap中使用JavaScript的Google导航 - Google navigation using javascript in Cordova/Phonegap 科尔多瓦的Windows Phone问题8 - Cordova problems with windows phone 8 Windows Phone 8 Javascript画布不在整个页面上 - Windows Phone 8 Javascript canvas not on whole page 在Windows 8和Windows Phone 8上使用带有HTML5 / Javascript的F#可移植库 - Using an F# portable library with HTML5/Javascript on Windows 8 and Windows Phone 8 Apache Cordova中的HTML模板? - HTML Templates in Apache Cordova?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM