关于在 Facebook 中使用 FBML,我应该了解哪些信息?
我的任务是为酒店开发一个相当简单的预订控制台。它具有两个具有相应选项卡的
到目前为止,我计划在主 HTML 下方嵌入 style
和 script
元素。
问题1.1:对于HTML,我可以直接做我想做的事,还是受到限制?对于表单之类的普通旧东西,我是否必须使用任何 facebook 特定元素?
以下是我将使用的代码片段示例:
<ul>
<li id="tab"><a href="#blah">text</a></li>
<li id="tab2"><a href="#blah">text</a></li>
</ul>
<form id="hidden">blah</form>
<script>
(function() {
var tab = document.getElementById('tab'),
tab2 = document.getElementById('tab2');
tab2.onclick = function() {
document.getElementById('hidden').style.display='';
return false;
}
})();
</script>
<style> #hidden { display:none; }</style>
问题 1.2:这段代码有陷阱吗?由于 Facebook 转换标记和 js 的方式,依赖私有命名空间/匿名函数是否不好?我是否应该使用内联事件处理程序(例如 onclick
)来实现基于事件的行为,因为 Facebook“转换器”更容易解析它并“重新编译”它?
其他背景信息:
这个小部件没有任何类型的 共享按钮、登录、图片。它 几乎将包括一个 到达/出发文本字段、下拉菜单 对于成人/儿童,以及一个提交按钮。 这适用于两种形式。
I've been tasked to develop a fairly simple reservation console for a hotel. It features two <form>
s which have corresponding tabs, the active tab applies to the default form and the inactive tab applies to the hidden form. The tabs are clickable and would enable/disable their respective forms.
So far what I am planning is having embedded style
and script
elements below my main HTML.
Question 1.1: For the HTML, can I just go ahead and straight up do what I want, or am I restricted? Do I have to use any facebook specific elements for plain old stuff like forms?
Here's an example of a snippet I would use:
<ul>
<li id="tab"><a href="#blah">text</a></li>
<li id="tab2"><a href="#blah">text</a></li>
</ul>
<form id="hidden">blah</form>
<script>
(function() {
var tab = document.getElementById('tab'),
tab2 = document.getElementById('tab2');
tab2.onclick = function() {
document.getElementById('hidden').style.display='';
return false;
}
})();
</script>
<style> #hidden { display:none; }</style>
Question 1.2: Are there pitfalls with this code? Is it bad to rely on private namespacing / anonymous functions because of the way Facebook converts the markup and js? Should I be using inline event handlers such as onclick
for event based behavior because it would be easier for the Facebook "converter" to parse it and "recompile" it?
Other background info:
This widget does not have any sort of
share buttons, login, pictures. It
pretty much will consist of an
arrival/departure textfield, dropdowns
for adults/kids, and an submit button.
This goes for both forms.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于 FBML,需要了解的主要一点是,Facebook 已弃用 FBML 页面,转而使用 iframe页。使用新 iframe 页面的好处是,您几乎能够在页面上使用 css、html 和 javascript 执行任何您想要的操作。正如您所询问的 FBML 存在很多问题,但其中大部分已经消失。
The main thing to know about FBML is that Facebook has deprecated FBML pages in favor of iframe pages. The good thing about using the new iframe pages is that you are pretty much able to do whatever you want on your page in terms of css, html, and javascript. There were a lot of gotchas as you were asking about with FBML but a majority of those have gone away.