How can I pass parameters to a local page in PhoneGap app?

后端 未结 3 1437
野的像风
野的像风 2021-01-15 15:08

In a PhoneGap app, we can setup the starting page using the following code.

self.viewController.wwwFolderName = @\"www\";
self.viewController.startPage = @\"         


        
3条回答
  •  灰色年华
    2021-01-15 15:39

    If I was you, I would just pass all of the information to javascript via a plugin method that you will create(i.e. plugin.GetQueryString() ) You can create a general plugin method that will return all of the query parameters as a string, and then you can process it in javascript with a following method:

    function getQueryParams(qs) {
        var params = {},
        tokens,
        re = /[?&]?([^=]+)=([^&]*)/g;
    
        while (tokens = re.exec(qs)) {
            params[decodeURIComponent(tokens[1])]
            = decodeURIComponent(tokens[2]);
        }
    
        return params;
    }
    
    window.$_GET = getQueryParams(plugin.GetQueryString());
    

    As a result you will get a nice data structure with all of your GET parameters that you can access by name.

提交回复
热议问题