So I have this url: /somepage/goes-here/something?image=main_image.jpg&type=shirt
How do I get out the two different attributes to then apply an eventListener to them?
I've tried the following:
var originalUrl = window.location.href
var type = originalUrl.search.get("type");
var image = originalUrl.search.get("image");
But I don't really think I'm getting the attributes with .search.get. Plus it errors with .search.get("type") is not a function.
I've also tried the following:
function getParam(param){
return new URLSearchParams(window.location.search).get(type);
}
I'm honestly not too familiar with URLSearchParams but wouldn't it be similar to above? How would I get both params here?
I also have for jQuery, which I'm not familiar with, the following:
$(function(){
$.url.attr('image')
$.url.attr('type')
});
This one...no idea. But it fails as it's not bringing in the url.