I need to look at a href in a page and see if a certain bit of text is in the URL, if it is i need to change it to something else, then append a location to the end.
if the link contains “ice/app?service=page&page=probrowse”
ex: http://www.google.com/ice/app?service=page&page=probrowse&cat=1&year=2011
I need to change it to “club/probrowse.htm?”
ex: http://www.google.com/club/probrowse.htm?cat=1&year=2011
I am currently running the script below which takes into consideration ? and & in the URL and appending a location to the href.
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('a').attr('href', function() {
return (this.href.indexOf("?") >= 0) ? this.href + "&location=/abc/123" : this.href + "?location=/abc/123";
});
});
</script>
I ran into some other bumps due to the fact I am ingesting information from another site and need to make some minor URL changes.
The overall goal is to change
google.com/ice/app?service=page&page=probrowse&cat=1&year=2011
into
google.com/club/probrowse.htm?cat=1&year=2011&location=/abc/123
I belive this is what you are looking for: