I found this snippet of code, which works a treat:
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (!results) { return 0; }
return results[1] || 0;}
}
So if the url/query string was xyz.com/index.html?lang=de
just call var langval = $.urlParam('lang'); and you've got it
--
My information is coming from clicking on an image, so I created this code:
$('#admin-slideshow img').click(function() {
alert($(this).attr('src'));
}
So if the code was:
<a href="#"><img src="image.php?url=image.jpg&tid=1&opn=1" /></a>
it would alert just that (image.php?url=image.jpg&tid=1&opn=1).
My brainiac thought was to add that snippet of code $(this).attr('src'); and replace it with the window.location.href. It doesnt work. Any suggestions?
$('#admin-slideshow img').click(function() {
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec($(this).attr('src'));
if (!results) { return 0; }
return results[1] || 0;}
}
}