Piotr Krysiak
Piotr Krysiak

Reputation: 2815

Javascript in another location

I am making a jQuery Mobile and Phonegap application. It works very well on Chrome, Safari and Firefox, but on android device it doesn't. I search a bit and I think that my problem lies in .js files localized in another folder. They don't seem to be added/loaded to my app. That the example that does not work:

    $('#contact_add').live('vclick', function(event) {
                $.showPageLoadingMsg;
                **clearContactStorage();**
                window.location.href = ('file:///C:/Users/add.html');
            });

Here is head definition:

<script src="file:///android_asset/www/js/clearStorage.js"></script>

And here is the function in .js file:

function clearContactStorage()
{
window.localStorage.setItem('uwagi', 'Uwagi...');
window.localStorage.setItem('idCustomerLabel', 'Kontrahent...');
console.log('Cleaning contactStorage');
}

Upvotes: 0

Views: 71

Answers (1)

Littm
Littm

Reputation: 4947

I think your need to change the source of your javascript file:

Change:

<script src="file:///C:/Users/Praktykant/workspace/TopFirma/assets/www/js/clearStorage.js"></script>

To:

<script src="./js/clearStorage.js"></script>

The paths you define for the sources must take into account that your folder www is the root folder.

If it's not working, you may need to transfer all the javascript functions defined in your file clearStorage.js to your HTML file (in <script> tags)

Let me know if this works

Upvotes: 1

Related Questions