开发者

tips on writing my first html embeddable widget?

I have been asked by a client to develop a javascript(mootools)/html/css/php based game as a widg开发者_运维百科et which can be deployed anywhere.

I have not written a widget before, so would love to get some tips and experiences so that I know some of the pitfalls before i start!


Encapsulate your variables. Don't put anything in the global namespace, because you don't want to conflict with anything else operating there.

Ideally, let your widget write itself into the page; that reduces the number of separate things that have to be dropped into the page by the user, thus making it easier to install.

Make it clear what requirements your widget has - if it needs external libraries like MooTools to function, the person installing the widget will need to know that.


First of it depends of what you mean with anywhere? How much code are you allowed to publish to "anywhere".

Any how, the simplest way to publish anywhere is to just send "anywhere" a that implements the game. If you need different variables from each "anywhere" (for example for tracking) you can specify a .php file in the src attr that generates a javascript base on the parameters.

In the script you can use AJAX to talk to your sever and document.write to write at "anywhere" page.

One thing to keep in mind is that using a JS library could be hard since the "anywhere" page might no implement the specific JS library.


good related thread.. Widget -what to do and what not

thanks for answers so far - the more the better!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜