开发者

How does social plugin work?

Introduction

I am planning to create a widget much like, Facebook provides for likes, share etc. Basically the requirement is:

  1. The client will include JavaScript provided by us.
  2. The client can, now, put our widgets in the page having the JS. The widget placeholder looks like <nw:fav id="911"/>.
  3. When page gets loaded, the JavaScript replaces the placeholders with actual HTML. The JavaScript also keeps t开发者_C百科his DIV updated with dynamic (perhaps using long polling) content.

Problem

I am not sure how to do step #2.

  1. How JavaScript will get all the <nw:... tags and all the attributes of it?
  2. How to replace the tag with real HTML tag?

Constraints

  1. I am trying to avoid JQuery or any other JS library, since we may cause conflict if the client is also using JQuery, may be some other version.
  2. I don't really want to use IFrame.

I am looking for approaches. Open for suggestions.


The facebook connect JS SDK is open source. You might find the xfbml.js file useful. See this link.

Basically when the document loads, the code walks the dom looking for elements that have a specific namespace (FB uses fb, you appear to want to use nw). Find those elements and then replace them with whatever content you need.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜