为什么 Facebook 使用提交按钮而不仅仅是点赞按钮的链接?
我一直想知道为什么 facebook 使用类似“从按钮提交”而不只是简单的链接来执行操作,以下是类似按钮的代码。
<form rel="async" class="live_184361748268334 commentable_item autoexpand_mode" method="post" action="/ajax/ufi/modify.php" data-live="{"seq":0}" onsubmit="return Event.__inlineSubmit(this,event)">
<input name="charset_test" value="€,´,€,´,水,Д,Є" type="hidden">
<input autocomplete="off" name="post_form_id" value="1ef694751d74ce24382cfa6181f1adfe" type="hidden">
<input name="fb_dtsg" value="_19R5" autocomplete="off" type="hidden">
<input autocomplete="off" name="feedback_params" value="{"actor":"514782389","target_fbid":"184361748268334","target_profile_id":"514782389","type_id":"17","source":"1","assoc_obj_id":"","source_app_id":"2309869772","extra_story_params":[],"content_timestamp":"1298066944","check_hash":"e76c88ca6e20b4a0"}" type="hidden">
<div class="UIImageBlock clearfix"><i class="UIImageBlock_Image UIImageBlock_ICON_Image img sp_4b2fk0 sx_b64365"></i>
<div class="UIImageBlock_Content UIImageBlock_ICON_Content"><span class="uiStreamSource"><a href="/aleem.sheikh/posts/184361748268334"><abbr title="Saturday, February 19, 2011 at 3:09am" data-date="Fri, 18 Feb 2011 14:09:04 -0800" class="timestamp">4 hours ago</abbr></a></span><span class="UIActionLinks UIActionLinks_bottom" data-ft="{"type":"action"}"> ·
<button class="like_link stat_elem as_link" title="Like this item" type="submit" name="like" onclick="fc_click(this, false); return true;"><span class="default_message">Like</span><span class="saving_message">Unlike</span></button>
·
<label class="uiLinkButton comment_link" onclick="return fc_click(this);" title="Leave a comment">
<input value="Comment" type="button">
</label>
· <a title="Send this to friends or post it on your profile." href="/ajax/share_dialog.php?s=99&appid=2309869772&p%5B0%5D=514782389&p%5B1%5D=184361748268334" rel="dialog">Share</a></span></div>
</div>
<ul class="uiList uiUfi focus_target fbUfi" data-ft="{"type":"ufi"}">
<li class="ufiNub uiListItem uiListVerticalItemBorder"><i></i>
<input autocomplete="off" name="xhp_ufi" value="1" type="hidden">
</li>
<li class="ufiItem uiUfiLike">
<div class="UIImageBlock clearfix"><a class="UIImageBlock_Image UIImageBlock_ICON_Image" tabindex="-1">
<label onclick="this.form.like.click();"><i class="img sp_8dfqpl sx_4ac53f" title="Like this item"></i></label>
</a>
<div class="UIImageBlock_Content UIImageBlock_ICON_Content"><a href="http://www.facebook.com/profile.php?id=100000407120411">Syed Murtaza Zaidi</a> likes this.</div>
</div>
</li>
<li class="uiUfiComments uiListItem uiListVerticalItemBorder hidden_elem">
<ul class="commentList">
</ul>
</li>
<li class="uiUfiAddComment clearfix ufiItem ufiItem uiListItem uiListVerticalItemBorder uiUfiAddCommentCollapsed">
<div><img class="uiProfilePhoto actorPic UIImageBlock_Image UIImageBlock_ICON_Image uiProfilePhotoMedium img" src="http://profile.ak.fbcdn.net/hprofile-ak-snc4/41709_1014341698_4889488_q.jpg" alt="">
<div class="commentArea UIImageBlock_Content UIImageBlock_ICON_Content">
<div class="commentBox">
<textarea class="DOMControl_placeholder uiTextareaNoResize uiTextareaAutogrow textBox textBoxContainer" title="Write a comment..." placeholder="Write a comment..." name="add_comment_text" onfocus="return wait_for_load(this, event, function() {if (!this._has_control) {new TextAreaControl(this).setAutogrow(true);this._has_control = true;}});">Write a comment...</textarea>
</div>
<label class="mts mts commentBtn stat_elem optimistic_submit uiButton uiButtonConfirm" for="u127419_35">
<input value="Comment" name="comment" id="u127419_35" type="submit">
</label>
</div>
</div>
</li>
</ul>
<input value="{"src":10,"sty":263,"actrs":"514782389","object_id":184361748268334,"pub_time":1298066944,"fbid":"184361748268334","qid":"5575216616647978849","mf_objid":184361748268334,"s_obj":5,"s_edge":1,"s_prnt":3,"pos":9,"filter":"h"}" name="link_data" type="hidden">
</form>
I keep wondering why did facebook use like submit from button and not just simple link to do the action with, following is there like button code.
<form rel="async" class="live_184361748268334 commentable_item autoexpand_mode" method="post" action="/ajax/ufi/modify.php" data-live="{"seq":0}" onsubmit="return Event.__inlineSubmit(this,event)">
<input name="charset_test" value="€,´,€,´,水,Д,Є" type="hidden">
<input autocomplete="off" name="post_form_id" value="1ef694751d74ce24382cfa6181f1adfe" type="hidden">
<input name="fb_dtsg" value="_19R5" autocomplete="off" type="hidden">
<input autocomplete="off" name="feedback_params" value="{"actor":"514782389","target_fbid":"184361748268334","target_profile_id":"514782389","type_id":"17","source":"1","assoc_obj_id":"","source_app_id":"2309869772","extra_story_params":[],"content_timestamp":"1298066944","check_hash":"e76c88ca6e20b4a0"}" type="hidden">
<div class="UIImageBlock clearfix"><i class="UIImageBlock_Image UIImageBlock_ICON_Image img sp_4b2fk0 sx_b64365"></i>
<div class="UIImageBlock_Content UIImageBlock_ICON_Content"><span class="uiStreamSource"><a href="/aleem.sheikh/posts/184361748268334"><abbr title="Saturday, February 19, 2011 at 3:09am" data-date="Fri, 18 Feb 2011 14:09:04 -0800" class="timestamp">4 hours ago</abbr></a></span><span class="UIActionLinks UIActionLinks_bottom" data-ft="{"type":"action"}"> ·
<button class="like_link stat_elem as_link" title="Like this item" type="submit" name="like" onclick="fc_click(this, false); return true;"><span class="default_message">Like</span><span class="saving_message">Unlike</span></button>
·
<label class="uiLinkButton comment_link" onclick="return fc_click(this);" title="Leave a comment">
<input value="Comment" type="button">
</label>
· <a title="Send this to friends or post it on your profile." href="/ajax/share_dialog.php?s=99&appid=2309869772&p%5B0%5D=514782389&p%5B1%5D=184361748268334" rel="dialog">Share</a></span></div>
</div>
<ul class="uiList uiUfi focus_target fbUfi" data-ft="{"type":"ufi"}">
<li class="ufiNub uiListItem uiListVerticalItemBorder"><i></i>
<input autocomplete="off" name="xhp_ufi" value="1" type="hidden">
</li>
<li class="ufiItem uiUfiLike">
<div class="UIImageBlock clearfix"><a class="UIImageBlock_Image UIImageBlock_ICON_Image" tabindex="-1">
<label onclick="this.form.like.click();"><i class="img sp_8dfqpl sx_4ac53f" title="Like this item"></i></label>
</a>
<div class="UIImageBlock_Content UIImageBlock_ICON_Content"><a href="http://www.facebook.com/profile.php?id=100000407120411">Syed Murtaza Zaidi</a> likes this.</div>
</div>
</li>
<li class="uiUfiComments uiListItem uiListVerticalItemBorder hidden_elem">
<ul class="commentList">
</ul>
</li>
<li class="uiUfiAddComment clearfix ufiItem ufiItem uiListItem uiListVerticalItemBorder uiUfiAddCommentCollapsed">
<div><img class="uiProfilePhoto actorPic UIImageBlock_Image UIImageBlock_ICON_Image uiProfilePhotoMedium img" src="http://profile.ak.fbcdn.net/hprofile-ak-snc4/41709_1014341698_4889488_q.jpg" alt="">
<div class="commentArea UIImageBlock_Content UIImageBlock_ICON_Content">
<div class="commentBox">
<textarea class="DOMControl_placeholder uiTextareaNoResize uiTextareaAutogrow textBox textBoxContainer" title="Write a comment..." placeholder="Write a comment..." name="add_comment_text" onfocus="return wait_for_load(this, event, function() {if (!this._has_control) {new TextAreaControl(this).setAutogrow(true);this._has_control = true;}});">Write a comment...</textarea>
</div>
<label class="mts mts commentBtn stat_elem optimistic_submit uiButton uiButtonConfirm" for="u127419_35">
<input value="Comment" name="comment" id="u127419_35" type="submit">
</label>
</div>
</div>
</li>
</ul>
<input value="{"src":10,"sty":263,"actrs":"514782389","object_id":184361748268334,"pub_time":1298066944,"fbid":"184361748268334","qid":"5575216616647978849","mf_objid":184361748268334,"s_obj":5,"s_edge":1,"s_prnt":3,"pos":9,"filter":"h"}" name="link_data" type="hidden">
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为
BUTTON type="submit"
和INPUT type="submit"
是提交表单的标准方式,Because
BUTTON type="submit"
andINPUT type="submit"
are the standard way to submit forms我从来没有注意到它是一个按钮而不是一个链接,很好的捕捉。
这可能是因为“赞”操作不是真正的链接。它不会带你去任何地方。因此,虽然他们将其设计为链接,但它实际上并不是链接。当然,他们可以使用链接,但我认为使用按钮更正确。单击按钮会执行操作,而不是通过链接转到新页面。这与你在 Facebook 上“喜欢”某件事时所发生的情况非常吻合。
I never noticed that it was a button and not a link, nice catch.
It's likely because the "Like" action isn't a true link. It doesn't take you anywhere. So while they styled it like a link, it isn't actually a link. They could have used a link, sure, but I think using the button is a bit more correct. Clicking a button performs an action, as opposed to a link which takes you to a new page. That matches well with what happens when you "like" something on facebook.
甚至移动版本似乎也使用链接。该按钮一定是他们认为需要支持更严格的浏览器设置时留下的。 ——阿列克西
Even the mobile version seems to use links. The button must be a remnant from the time they thought they needed to support more restrictive browser settings. – Aleksi