douduan6731 2009-12-14 23:05 采纳率: 0%
浏览 160

如何为其他人提供代码以将您的内容嵌入到他们的HTML页面中?

Maybe the answer to this question is less complicated than I am making it...

I have a Zend Framework PHP web application. I am going to create a simple API that will output a report for the user's account. The content will be as simple as this:

<ul>
    <li>Item 1</li>
    <li>Item 2</li>
</ul>

I want to offer a code snippet that the user can use to embed the report on their own site.

I'm thinking this can be done with an iFrame, but I've never done this before so I don't know the best way to do this.

Update: If possible, I would also like to offer the ability for the user to style the content. Is that possible with an iFrame? I want the embedded content to look as much like the rest of the page as possible.

  • 写回答

3条回答 默认 最新

  • douliang2935 2009-12-14 23:09
    关注

    At its very simplest:

    Create a .js file with:

    document.write("<ul>");
    document.write("  <li>Item 1</li>");
    document.write("  <li>Item 2</li>");
    document.write("</ul>");
    

    Your users would then include this code wherever they wanted your embedded code to appear:

    <script type="text/javascript" src="http://example.com/path/to/file.js"></script>
    

    This approach allows them to style content. They wouldn't be able to style an IFRAME, but some sites providing IFRAMEable widgets solve this by allowing the user to pick colours, background images, etc. on a setup page.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?