Search code examples
javascripthtmlsearch-engine

How to tell search engines about custom JavaScript button target URLs?


I have made a website where I have my navigation buttons working via JavaScript. Is there a way to tell the search engine about the target URLs each button takes the user to?

Or should I try to rewrite it using anchor elements that have better compatibility?


Solution

  • Or should I try to rewrite it using anchor elements that have better compatibility?

    If it's a website, then yes, use anchor elements with straightforward href values, and then if you want fancy behavior as an add on if the user has JavaScript enabled, you can do that. This is not only friendlier to web crawlers, but to users who don't choose to have JavaScript enabled, and it may be better for accessibility as well.

    This is a concept called progressive enhancement, e.g., make the site fundamentally work without special extras like JavaScript or Flash or Silverlight or whatever, and then enhance the experience for users with those technologies enabled.