简体   繁体   中英

Changing pages issue moving a PhoneGap app to Mobile Web

Ok, so I've hit a wall. I've taken the code behind a PhoneGap App and lovingly crafted it into a Mobile Web App (essentially I just posted it on the server and was shocked when it didn't work).

I spent the next several hours unpicking everything that was PhoneGap centric, eg navigator.notification.alert() to window.alert(). After that I got the beast up and running. However I'm having issue with aa single issue regarding changing pages.

The original app was utilizing jQuery and jQuery Mobile. It was the basic single page paradigm where "pages" were linked ids within the single html. I've purged any link to PhoneGap. Now comes the issue. I was linking to seperate "pages" using:

$.mobile.changePage("#page1", {transition:"slide", changeHash:false});

Fairly common and should by my best guess and best Google searching still work in a mobile web page. However it doesn't. Fine I'll move away to something even more common and went over to window.location.repalce() then window.location.href = neither working. Then after some more Googling I noticed that people were having issues with browsers and I saw that my code was working in Chrome, but not in the standard Android Browser v5.5 Android version 4.3. Called a friend and it doesn't seem to work in a iPhone Safari browser iOS6 either. I figured fine, I'll come at this a different way and tore down the website and built it like an old style website with pages all linked and still nothing.

Any ideas of where to look next. No errors are being returned that I can find, the code just stops dead. When I put a window.alert after that page change it goes to the alert, but does not go to the page after I click on ok. It just stalls and does nothing.

Anything you could suggest as possible solutions I'm willing to give ago.

First off I was attempting to use a deprecated function, it is replaced with:

$.mobile.pageContainer.pagecontainer("change", "target", { options });

After that I found that this was a result of a faulty AJAX call. The weird thing that was throwing me off was that some items would work within the call (even though the call failed) and some would not.

The answer in my own case was to fix the PHP that the AJAX was calling and update my use of changePage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM