Trigger an event when page is loaded with a unique id (anchor link)

I need a button to be triggered on page load. Which I’ve figured out how to do with a window.onload function.

But what I need to figure out is how to trigger this only when the page is loaded from a unique id (eg the button would be auto clicked when visited from example.com/#xyz , but not triggered when visited from example.com).

I don’t know js much at all, so I’m not sure if this is even possible?

Thank you.

15 thoughts on “Trigger an event when page is loaded with a unique id (anchor link)”

Leave a Comment