0

I want to be able to toggle a javascript function that opens a certain tab on my page when the page loads. However I only want this function to run automatically when coming from another page.

For example:

Page A has the function that opens said tab, which is triggered when clicking on a button normally.

I want the user to click a button on page B and redirect to page A, where the function on page A automatically triggers.

However if the user reaches page A from anywhere but page B I do not want this function to trigger automatically.

This is the best way I can describe it, any help would be great. (I should also mention this is being done is ASP.NET MVC4)

1 Answer 1

2

You can use document.referrer. Something like this.

if (document.referrer === 'pageB') {
  // trigger the function
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.