将IFrame与Meteor一起使用 [英] Using IFrames with Meteor

查看:159
本文介绍了将IFrame与Meteor一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我毫不费力地寻找使用Merame和Iframe的例子。 (请注意,我必须使用iframe而不是DIV,因为最终会有内容)。我试过了两个:

I've fruitlessly looked for examples of using Meteor with an Iframe. (Note that I have to use an iframe instead of a DIV because of the content that will ultimately go there). I've tried both:

<body>
  {{> hello}}
</body>

<template name="hello">
  <h1>Hello World!</h1>
  {{greeting}}
  <input type="button" value="Click to see what you typed" />
  <br>
  <iframe id="compose" src={{> iframe-content}} height=600></iframe>
</template>

<template name="iframe-content">
  <body>
    <div contenteditable="true">
      Edit me
    </div> 
  </body>
</template>

递归加载,连续创建子iframe。

This loads recursively, creating sub-Iframes continuously.

我也试过了

<iframe id="compose" src="content.html" height=600></iframe>

但Meteor将多个HTML文件混合在一起,这也会导致iframe失败。

but Meteor munges the multiple HTML files together which also causes the iframe to fail.

到目前为止,唯一有效的是SRCDOC而不是SRC,但是FF等多种浏览器都不能很好地支持它。

The only thing that worked so far is SRCDOC instead of SRC, but that isn't well supported by multiple browsers like FF.

那么,在Meteor中使用iframe的诀窍是什么,最好是在模板中而不是严格地通过代码?

So, what's the trick to use an iframe within Meteor, preferably in the template rather than strictly through code?

推荐答案

你想要的'public'文件夹。 Meteor单独留下该文件夹中的内容,如下所述: http://docs.meteor.com/# / full / structuringyourapp

You want the 'public' folder. Meteor leaves content in that folder alone, as described here: http://docs.meteor.com/#/full/structuringyourapp

将'content.html'移动到项目/应用程序根目录下名为'public'的文件夹中,并像这样引用它html:

Move 'content.html' into a folder named 'public' at the root of your project/app and reference it like so in the html:

<head>
  <title>iframe</title>
</head>

<body>
  {{> hello}}
</body>

<template name="hello">
  <h1>Hello World!</h1>
  {{greeting}}
  <input type="button" value="Click" />

  <iframe src="hello.html"></iframe>

</template>

为了清楚其他读者,Meteor对iframe没有任何问题。问题在于'content.html'文件的位置引用了iframe。

To be clear for other readers, Meteor has no problem with iframes. The issue was with the location of the 'content.html' file the iframe referenced.

这篇关于将IFrame与Meteor一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆