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

后端 未结 3 1396
野的像风
野的像风 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:49

    In phonegap apps, you cannot call local pages by passing parameters to them because the system searches for files with exactly the same name as you pass. It doesn't treat the parameters as query string.

    Ex: when you say "index.html?param=abc", instead of calling page index.html with a
    parameter called param having value abc. It calls the page "index.html?param=abc"
    which doesn't exist in the system. Hence, the error.
    

    The best method to solve the issue is to save your parameters as local storages in the calling page, consume them in your next page and destroy them.

    Ex: In your calling JavaScript file, use:
    window.localStorage.setItem('param', 'abc');
    
    Now, in your called file, access the local storage and delete it
    param abc = window.localStorage.getItem('param');
    
    window.localStorage.removeItem('param');
    

    Hope that helps.

提交回复
热议问题