appending a query to a URL is a powerful way to pass information to new windows/ external webpages. This is accomplished by appending ‘?’ then a value to a URL ie. www.your-webpage.com/?hello
There are many ways to benefit from and apply this technique – generally the idea is that the webpage will initiate a process based on the query.

To utilize queries, the value must be extracted from the url of the page it was passed too.

Continue reading to see how we can accomplish this with JavaScript and jQuery

Paste the following code into a javascript file and import it before the end of your closing body tag.


//Wait till document is ready
$(document).ready(function()
{  

  //declare var to hold the query
  var query; 

  //extract the query from the URL
  query = url.substring(url.indexOf("?"))


  //do something based on the query result

  if(query == "hello")
  {
     //show a hello message
  }
   else if(query == "goodbye")
  {
     //show a goodbye message
  }


});