check if a certain query string is set then apply it to all url's on the page
this script will check if a query string is already set, and if it matches it will append the same query string to all url's on the page
Here is the test link with the field, and all url's on this page should now also have the query string myfield=true if this is not set then all url's will not have this query string.
With myfield=true
Without myfield=true
Javascript
$(document).ready(function() {
var field = 'myfield';
var url = window.location.href;
if(url.indexOf('?' + field + '=') != -1) {
$('a').each(function() {
var href = $(this).attr('href');
if (href) {
href += (href.match(/\?/) ? '&' : '?') + 'myfield=true';
$(this).attr('href', href);
}
});
}
});