webbist
webbist

Reputation: 456

onclick even after a href redirects?

Is it possible to have an onclick event happen after a page redirect? I have my Java files setup so there is a smooth scroll to "anchor2" after loading the new page but I can't for the life in me find a way to get the onclick function (Another java) to work on the new page.

<a href="portfolio.html#anchor2" onclick="javascript:showAndScroll(1, 3)" title="">Link</a>

The following works on the portfolio.html page to open/close sections onclick

 <a onclick="javascript:showAndScroll(1, 3)" title="">Link</a>

But I want this functionality when on a different page to portfolio so that it links to portfolio.html and the ID (smooth scrolls to #anchor2) and then the onclick even to happen?

Here is the Fiddle

Is this possible?

Upvotes: 0

Views: 582

Answers (1)

Sergio
Sergio

Reputation: 8259

You are looking the problem the wrong way.

You cannot create an event for "After new page load", but you can do "After page load".

So, try to catch your anchor on page load and there execute your function.

Upvotes: 2

Related Questions