Y
Y
Yura_Mart2019-03-06 10:47:56
JavaScript
Yura_Mart, 2019-03-06 10:47:56

How to get data from address bar in app on phonegap?

Hello!
There is a cross browser app on phonegap. On the front, all work is done with html + js.
There is a task: to select that page in the menu on which there is a user.
As I see it: take a piece from the url, and make a check, which adds a class.
Here's what happened:

let URL = window.location.pathname;
    if(URL == '/index.html'){
        $(".go_to_index").addClass('active-item');
    }

All this works fine in a browser on a PC, but if you check it through phonegap on your phone, then nothing works.
I found that "window.location.pathname" doesn't work outside of the browser.
There is an implementation option through localstorage, but there is a nuance that it will only work when clicking on the page, but smartphone users use the back button on the phone to return, so localstorage will not be overwritten.
What are the alternatives for url stripping?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question