onClick 会影响 SEO 价值吗?

发布于 2024-09-15 18:03:57 字数 214 浏览 3 评论 0原文

我想知道使用常规的 href 链接或通过添加 javascript onclick 使元素可点击之间是否有任何 SEO 差异?

我的两个选择的基本示例......

<a href="myUrl">Link</a>

<div onclick="javascript:yUrl">Link</div>

I wonder if there's any SEO difference between using a regular a href-link or making an element clickable by adding javascript onclick?

Basic example of the my two options...

<a href="myUrl">Link</a>

<div onclick="javascript:yUrl">Link</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清秋悲枫 2024-09-22 18:03:57

由于网络蜘蛛(仍然)不受 Javascript 影响,因此这两段代码之间的明显区别是,一段代码可以被机器人(以及其他任何人)跟踪,而另一段代码仅适用于启用了 Javascript 的用户(因此,不适用于 Google) 。对于蜘蛛来说,它应该只是一个 div,并且您使用 onclick 设置的任何 url 都不会被遵循(因此,不会从该页面建立索引)。

Since web spiders are (still) Javascript-free, the obvious difference between the two bits of code is, one can be followed by a bot (and anyone else) while the other only works for users with Javascript enabled (so, not Google). For spiders, it should be nothing more than a div, and whatever url you're setting with onclick will not be followed (and therefore, not indexed from that page).

恏ㄋ傷疤忘ㄋ疼 2024-09-22 18:03:57

Possibly, it's known that Google executes some JavaScript. I don't know why you would want to do this though. If you are trying to stop browsers folowing links, you could try rel="nofollow".

遗失的美好 2024-09-22 18:03:57

通常情况下,是的。总的来说,爬虫只关心标记,而不关心 JS 修改的过渡状态,因此 JS 创建的链接对它们来说是不可见的(这本身可能是一个有用的东西)。造成这种情况的一个原因是 JS 引擎比爬虫所需的要复杂得多,另一个原因是 JS 根本不希望修改内容,而只是修改行为。锚点是用于这些关系的语义结构。

搜索所有者将他们的机制隐藏起来,但过去曾为一个 [无关紧要的] 工作过,我可以说带有 href 的锚点基本上是我们的爬虫考虑的唯一事情,并且带有 rel 的锚点得分很高。

Typically, yes. Crawlers by-and-large just care about the mark-up, not the transitional state as would be modified by JS so a JS created link will be invisible to them (which may be a useful thing in it's own right). One reason for this is that JS engines are a layer of considerable complication above what a crawler requires and another is that JS is simply not expected to modify the content, just the behaviour. Anchors are the semantic structure intended for these relationships.

Search owners keep their mechanisms hidden but having worked for one [insignificant one] in the past I can say that anchors with hrefs were basically the only thing our crawlers considered, and anchors with rel were scored highly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文