I’ve been searching for this on google en SO, i got the function that i wanted to get the query paramaters from the url (link to article).
But i can’t find an answer to my question, which i’m pretty positive about is that it should be prety easy to fix, i even feel foolish to ask, but i just can’t find this specific answer.
When i click a link and i catch that click in jquery, the function returns false (i don’t want a refresh), so the parameters that i want are not parsed into the url. How do i get these?
CURRENT URL: index.php?page=search&action=searchAll
<h4 class="videoLink"><a href="index.php?page=search&action=playVideo&isAjax=true&v={$result.link}" class="{$result.link}">{$result.title}</a></h4>
jQuery simplified
$('.videoLink').click(playVideo);
function playVideo(){
url = getUrlVars();
return false;
}
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;
}
So when i trace url, i only get the params: page & action
Before returning
falseyou can get the link and extract the parameters..Update
If you want your code to work with the browser location as well as custom urls passed to it, you can change it to
and call it like this