Do something different based on multiple different URL parameters

Do something different based on multiple different URL parameters

I have the following script started and need to trigger certain modals to open on page load, based on the URL string. For example, if 'src' is equal to '123', then modalBuyer needs to appear. If 'src' is equal to '234', then modalSeller needs to appear. Here's what I have so far. This was created back when there was only one modal that ever needed to be shown on page load.

  1.     if (window.location.href.indexOf('src=') > 0) {
  2.     $(window).on('load',function(){
  3.             $('#cModal').modal('show');
  4.             });
  5. }
I was considering doing something like this, but was curious if there might be a better way:

  1. var src= (new URL(location)).searchParams.get('src')

  2. var SRC_LOOKUP = {
  3. 123: "modalBuyer",
  4.                         234: "modalSeller",
  5.                  }