Reputation:
Is it possible to append a string to url using the body? Something similar to the JSFiddle below.
<a href="#" onclick="extendSearch('&page=2');return false">hi</a>
I want to append this query to the url: ?q1=iPodTouch&x=79&y=20
When the user clicks the link they will be taken to the next page with the attached string above.
Upvotes: 0
Views: 12064
Reputation: 1422
Updated :
No need to pass it on another function ,
Use like this:
<a href="http://xxxxxx.com/xx-xxxxxx" onclick="location.href = $(this).attr('href')+'?q1=iPodTouch&x=79&y=20';return false">Navigate</a>
Upvotes: 1
Reputation: 32921
If you wanted to utilize jQuery more you could try this approach.
$('a[data-page]').on('click', function(e){
e.preventDefault();
var page = $(this).data('page');
location.href += ( location.search.length ? '&' : '?' ) + 'page=' + page;
});
and have the HTML look like:
<a href="#" data-page="2">Page 2</a>
Upvotes: 0