开发者

The "rel" attribute

I have开发者_JAVA百科 noticed that the "rel" attribute is not used at all by browsers, does this make it an ideal place to store additional information for javascript (eg a delete ajax request could read the id from rel)


I'm assuming you are looking for a way to store custom data you can use in javascript. I that case:

Storing custom data can be done using data- attributes (see here).

<a href="somelink.html" data-id="5">Link 5</a>

Alternatively/additionally you could use jQuery Metadata


I have noticed that the "rel" attribute is not used at all by browsers

You noticed wrong. Browsers do make use of it (e.g. some browsers have a keyboard shortcut to go to the next page and can use the rel attribute to determine that that is). Search engines also make use of it (e.g. nofollow).

does this make it an ideal place to store additional information for javascript

No. Attributes have specified purposes. Don't assume that they aren't going to be used for that.


The problem you'll have is that search engines do make use of the rel attribute. While SEO is not my focus, we often have SEO firms telling us to stick a rel in here and a rel in there... usually rel="nofollow" to prevent giving weight to certain external links.


You could just create your own custom attributes but make sure that you name it currently as to not conflict with other js libraries that you may use.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜