开发者

javascript onclick based links?

开发者 https://www.devze.com 2023-01-06 03:39 出处:网络
I have seen many websites includes apple and most of asp.net sites uses <a onclick=\'s_objectID=\"http://www.apple.com/mac/_2\";return this.s_oc?this.s_oc(e):true\'></a>

I have seen many websites includes apple and most of asp.net sites uses

<a onclick='s_objectID="http://www.apple.com/mac/_2";return this.s_oc?this.s_oc(e):true'></a>

kind of links. i.e. no href on a tag. and link embedded to onclick event.

what are the reas开发者_JS百科ons for that ? analytics ?

How does it affect on seo ?


This is most likely analytics tracking code used by Adobe SiteCatalyst (formerly Omniture). Check to see if the page contains a script called s_code.js or something similar. If you search the minified code, you will see that it utilizes s_oc.


Well in ASP.NET the links that have onclick only defined are LinkButtons - a specially formulated link that causes a postback. I'm not a big fan of it purely for the reason that it creates nasty inline JS. I'm not sure for what purpose Apple uses the links you mentioned.

As for SEO - it all depends on the engine, I know Google do follow some javascript links but not all engines do. In general its best practice (and not only for SEO) to not put inline JavaScript into your links (or any other elements). It is not accessible, it makes your site harder to maintain and its just ugly.


Some websites will use this technique for analytics. Also, sometimes people will use it to hide the URL when people hover over the link or to customize where the URL goes. Also, it can be used to send extra data along with the URL (ie. the contents of a form). However, this is terrible for search engines when they are crawling your page because they can't figure out where the URL points to and they can't index it.


There is some kind of operation in this link. If you loook at the code

return this.s_oc?this.s_oc(e):true

it is enabling and disabling the link. if condition s_oc true, then the link works else link not works. THis will help there own analytic purpose.

btw, in SEO aspect. href is the best visible to Search Engines. As because OnClick execute as Javascript function, Search Engines will not process this.

0

精彩评论

暂无评论...
验证码 换一张
取 消