window.location.href vs window.open()vs AJAX-英特尔XDK中的WP8应用程序



我正在使用英特尔SDK开发HTML5应用程序,为Windows Phone 8平台编译,并在诺基亚Lumia 530上部署和测试。

我在这个场景里。我必须从同一个应用程序中执行3个不同的操作:(1)对系统浏览器的调用传递URL,(2)对系统电话应用程序的调用传递电话号码,(3)对API的ajax调用。

我的问题是window.open()不适用于链接"tel:123456789",如果尝试使用window.location.href进行电话操作,我在电话呼叫后返回应用程序后无法使用window.open()。似乎window.location.href禁止/阻止应用程序上下文使用window.open().

这是我的代码,为了清晰起见,我尝试了所有组合:

HTML

<button class="ui-btn my-button" id="button1">Bottone 1</button>
<button class="ui-btn my-button" id="button2">Bottone 2</button>
<button class="ui-btn my-button" id="button3">Bottone 3</button>

JS[内部var onDeviceReady=function(){}]:

$("#button1").on("click", function () {         
    window.open ('http://www.google.it', '_blank'); // WORKS PERFECTLY BEFORE I CLICK BUTTON 2, DOESN'T WORKS AFTER
});  
$("#button2").on("click", function () {         
    window.open ('tel:123456789', '_blank'); // WORKS BUT BLOCKS OTHERS BUTTONS ACTIONS AFTER COME BACK IN APP FROM TELEPHONE CALL
    //window.open ('tel:123456789', '_system'); // DOESN'T WORKS, BUTTON CLICK HAS NO EFFECT
    //window.open ('tel:123456789', '_self'); // DOESN'T WORKS, BUTTON CLICK HAS NO EFFECT
    //window.location.href = 'tel:123456789', '_blank'; // WORKS BUT BLOCKS OTHERS BUTTONS ACTIONS AFTER COME BACK IN APP FROM TELEPHONE CALL
    //window.location.href = 'tel:123456789', '_system'; // WORKS BUT BLOCKS OTHERS BUTTONS ACTIONS AFTER COME BACK IN APP FROM TELEPHONE CALL
    //window.location.href = 'tel:123456789', '_self'; // WORKS BUT BLOCKS OTHERS BUTTONS ACTIONS AFTER COME BACK IN APP FROM TELEPHONE CALL
}); 
$("#button3").on("click", function () { 
    // WORKS PERFECTLY BEFORE I CLICK BUTTON 2, DOESN'T WORKS AFTER
    $.ajax({
        type: "GET",
        url: 'https://customers.clouditalia.com/public/ws_etnicom_ri?numerochiamato=05...',
        cache: false,
        dataType: "text",
        success: function (data) {                
            alert(data);
        },
        error: function (data) {
            alert("ERROR: response = " + data);
        }
    });
}); 

有人能帮我吗?

您可能可以使用另一个调用,如:

$.mobile.changePage("#button1"); 

其中#button1是要转到的页面的id。

相关内容

  • 没有找到相关文章

最新更新