I'm accessing the URL parameters with javascript. Then I manipulate the DOM with jQuery Mobile. But when I access the html file with the parameter, it doesn't show. I need to refresh the page to make it work. What can I do?
Javascript:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var vars = getUrlVars()
console.log(vars.institutname)
$("#tasksPage").find("h1").append(vars.institutname)
})
</script>
EDIT
I just noticed that NONE of the jQuery/javascript is executed. To be clear: I have a link to that html page with the URL parameter. But if I click on that link and the page opens, it does not execute my code. I need to refresh to make that work.
I'm using jQuery Mobile.