onClick 会影响 SEO 价值吗?
我想知道使用常规的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于网络蜘蛛(仍然)不受 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).
众所周知,Google 执行一些 JavaScript< /a>.我不知道你为什么要这样做。如果您试图阻止浏览器跟踪链接,您可以尝试
rel="nofollow"
。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"
.通常情况下,是的。总的来说,爬虫只关心标记,而不关心 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.