Question

I'm new to Javascript and this is "my" "filtering function" for my project:

This is my function "auth" to authenticate my label:

function auth() {
if ($('#Resultat_mobilelabel_resultat:contains("Nautnes")').length > 0) {
    document.getElementById('Resultat_mobilelabel_sted').innerHTML = 'Nautnesveien nord';
} else {
    alert("some error")
        Appery.navigateTo('startScreen', {
            reverse: false
        });
    }
}

and this is how im trying to run the function:

// On Load
screen_1665_onLoad = Resultat_onLoad = function() {
    auth();
}

But somehow it does not load the function when the page is loaded... Any suggestions? Thanks!

Was it helpful?

Solution

Try this:

(screen_1665_onLoad = function() { auth(); })();

That should run when the page loads.

Then again, you're using jQuery so why not go for the stock-syntax:

$(function() {
auth(); // This is your function-call, which will run once jQuery determines the document is ready
});

OTHER TIPS

Looks more like you are assigning screen_165_onLoad with a function than actually calling the function

try this: $(document).ready(function(){ auth(); });

at the end of the page

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top