Has link with a URL in onclick attribute

This means that the URL in question contains at least one outgoing anchor link with a URL in an onclick attribute.

Why is this important?

This is a type of JavaScript link - the onclick attribute defines a JavaScript action when the 'onclick' event for the link is triggered (i.e. when a user clicks the link) - and there is a URL present itself in the onclick attribute.

This means that the link destination is JavaScript dependent, which search engines can struggle with. Of all the search engines, Google is best set up to handle JavaScript rendering, and they claim to sometimes struggle with such links.

John Mueller Twitter

What does the Hint check?

The Hint will trigger for any internal URL that has at least one outgoing link, where the link includes a URL in an onclick attribute.

Examples that trigger this Hint

An anchor with an onclick attribute, with a URL defined in the onlick attribute

<a href="javascript:void(0);" onclick="window.location.href='https://example.com'">onclick link!</a>

How do you resolve this issue?

It is difficult to give clear-cut advice regarding the use of JavaScript, as the landscape is constantly changing, with search engines getting better at understanding JavaScript all the time. However, there is an inherent danger in using JavaScript links that search engines may not be able to follow the links (particularly search engines not named Google).

To really understand if the links are 'working' in your situation, you would need to analyse search engine behaviour directly through log file analysis.

The prudent option would be to ensure there is some sort of HTML fallback, or simply to use HTML links instead;

  • Replace JavaScript links with HTML links.
  • Or, if your site content is heavily JavaScript dependent, you may wish to serve pre-rendered pages to search engines.

How do you get more data from Sitebulb?

From the URL List, click the blue Hint Details button, which will bring up a slide-across window with specific details about the Hint for each URL.

Link in onclick

Further Reading

Ready to try Sitebulb?
Start your free 14 day trial now

Start Free Trial