了解如何让天才为我的用户(JavaScript代码段)我的、天才、代码、用户

2023-09-10 21:49:07 作者:最是那一低头的温柔

我想给我的用户的一小片的JavaScript或HTML code,他们可以把自己的网站,并显示相关信息。有点像StackOverFlows新功能天才。

I wanted to give my users a little piece of JavaScript or HTML code that they could put on their site and show information about them. Kind of like StackOverFlows new feature Flair.

我对如何code这一个想法。我打算给他们一些JS与HTML是有一个DIV ID =MySite_Info。然后,JS会去我的网站和拉一些JSON或XML,然后填写资料,在我给他们在其网站上的HTML一个DIV。

I have an idea of how to code it. I was going to give them some JS with a HTML that had a DIV id="MySite_Info". Then the JS would go to my site and pull some JSON or XML and then fill in the data with a DIV in the HTML I gave them on their site.

有没有更好的方式来做到这一点?或任何的例子在网上我应该遵循?最新最好的方式来创建这些JavaScript代码段? (不知道什么是正确的名字)

Is there a better way to do this? Or any examples online I should follow? Whats the best way to create these javascript snippets? (Not sure what the proper name is)

推荐答案

有两种基本的选择。

图片(文字和图片吸) JavaScript的 - 像你描述

我会采取的做法是:

在动态使用服务器端程序生成的JS。这将包括用于用户数据(使用JSON发生器容易地制造在一个合适的格式的数据)。 在使用标准DOM方法生成的徽章 找到的文件ID的元素,并使用appendChild生成的徽章
 
精彩推荐
图片推荐