drake035
drake035

Reputation: 2877

Executing jQuery code when visiting a page with anchor tag in the URL

On a certain page, I want to execute jQuery code when: (1) the user arrives to that page from a different page, and (2) through a URL that has an anchor tag in it (site.com/page#anchor_tag). Is that possible in jQuery?

Upvotes: 0

Views: 34

Answers (1)

Barmar
Barmar

Reputation: 780724

For (1) check document.referer to see if you came from a different page.

For (2) you can use window.location.hash to get the part of the URL beginning with #.

Upvotes: 2

Related Questions