douhuiqi3855 2014-10-07 10:42
浏览 101

我想创建一个小部件,它将在将Widget添加到其网页的网站上呈现应用程序

I want to create a widget or a javascript code which will render a HTML form on the webpage where the code is embedded.

eg. www.example.com wants to show a BMI calculator which is hosted on www.example2.com example2 wants to share that BMI with example.com but is not giving the actual code. He will share just a js code ( Like how we include Google Analytics or Google Ads ). Whats the best way to achieve this?

In this calculator we are asking multiple details from the user which are saved in database on www.example2.com in db .

I don't want to go Java Applet or Flash way. Currently I have to share HTML code of the BMI calculator which is not ideal.

What are the possibilities here.

Thanks

  • 写回答

1条回答 默认 最新

  • doucheng4660 2015-11-23 09:31
    关注

    There are two ways to do this: the iframe and javascript.

    The more common way is to use the iframe, as it is a simple webpage on which you have full control. More, the best advantage is that the iframe is loaded asynchronously so the loading of the page isn't affected by the loading of the widget.

    This is the approach that Facebook uses and as it does, also all other major sites use the same approach.

    As pointed out in comments, using iframes permits you to use also the cookies, load css, javascript, ecc as it is a full webpage.

    to use iframes you have to use a code like this:

    <iframe id="WidgetContent" src="http://example.com/widget/id" frameborder="0" height="600"></iframe>
    

    It's very simple!

    评论

报告相同问题?

悬赏问题

  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件