【问题标题】:Using An Iframe for an embedded App为嵌入式应用程序使用 iframe
【发布时间】:2011-09-10 15:28:39
【问题描述】:

我目前正在编写一个可以嵌入的网络应用程序。 我想知道通过包含的 Javascript 文件为界面生成 iframe 是否是一个好习惯?

例如,用户只需将其包含在他们的索引页面中:

<script src="App.myurl.com/Application.js"/></script>
Init_App("[User_Public_Authorization]");

Application.js 然后会生成一个包含应用程序 PHP 代码的 Iframe。

【问题讨论】:

    标签: php javascript web-applications embed


    【解决方案1】:

    在编写脚本之前,您应该始终问自己是否真的需要它。

    您要做的是加载一个脚本,然后创建一个 iframe,然后加载您的应用程序。

    更简单的解决方案是只使用 iframe。

    您将从脚本中获得哪些好处?

    你的脚本能做哪些普通 iframe 做不到的事情?

    使用 iframe 标记,如果您需要特定于站点的参数,请将它们放在查询字符串中

        <iframe 
         src="App.myurl.com/Application.php?width=200&height=300" 
         width="200" 
         height="300" >
             <p>your browser does not support iframes</p>
        </iframe>
    

    使用 javascript 生成 PHP 代码毫无意义,因为 PHP 是在服务器上执行的。

    相信我你不应该在你的服务器上运行由客户端生成的代码

    【讨论】:

    • 感谢您的提示,我最需要创建脚本,以便创建一种不显眼的界面。我认为您误解了 PHP 生成,但 iframe 的 SRC 将是位于我的服务器上的 PHP 脚本,就像您在示例中显示的那样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-06
    • 2010-11-27
    • 2011-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多