javascript - Add a query string to anchor link from query embedded in current URL -


how dynamically add "?q='query'" (where 'query' query string search box , embedded in the current page url example.com/search/?='query') anchor link on page?

an example of can found on website: https://www.ecosia.org/search?q=test

here page include links '?q=test' query added them (e.g. https://www.ecosia.org/images?q=test)

thank help

this append querystring page url onto every link on page.

var qs =window.location.search;  $('a').each(function(){     var href = $(this).attr('href')     $(this).attr('href',href+qs) })  

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -