簡體   English   中英

phonegap window.location onDeviceReady 不起作用

[英]phonegap window.location onDeviceReady not working

我正在嘗試將我的移動網站放入 PhoneGap 以創建一個“本機”應用程序。 因此我開始谷歌搜索,發現 onDeviceReady window.location 應該可以解決這個問題。

例如,這里已經描述了這個解決方案: http : //antonylees.blogspot.de/2013/02/launch-website-as-mobile-app-using.html

但是,按照選項 2(僅包含 window.location)解決方案,它不起作用。 顯示警報但 window.location 不起作用,這意味着它不顯示新窗口位置,而只顯示原始 phonegap 加載屏幕。 (當前頁面的警報包含與警報后相同的消息)

有什么想法嗎?

這是 index.js 的相關代碼部分

onDeviceReady: function() {
    app.receivedEvent('deviceready');
    alert(window.location.href);           //current page
    window.location = "https://www.google.com";
    alert(window.location.href);          //page after location set
},

這是 config.xml 的相關部分

  <access origin="*"/>
  <allow-navigation href="*" />

哦,我剛剛為 windows 安裝了最新的 phonegap,創建了一個新項目,並且剛剛更改了 index.js,如上所示。

非常感謝

我從 phonegap 示例開始 - https://github.com/phonegap/phonegap-start

根據您的帖子更改了 config.xml

<access origin="*"/> <allow-navigation href="*" />

我更改了接收到的事件,在 js/index.js 中更改 window.location

// Update DOM on a Received Event
receivedEvent: function(id) {
   window.location =  "http://your.domain.com";
}

它似乎適用於 IOS ad_hoc 的 build.phonegap.com。 我還沒有在應用商店中嘗試過構建

對我來說同樣的問題。 在我周圍工作幾天后,弄清楚。

將此行添加到我的 config.xml

<plugin name="cordova-plugin-whitelist" spec="1" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM