2013-08-23 37 views

回答

4

虽然你可以很容易使一个固定的iframe使用render功能,也有一个SproutCore视图SC.WebView,在:desktop框架中为您执行此操作。如果您希望src发生更改,或者您想调整iframe的大小以匹配其内容的大小,则应该使用SC.WebView

例如,

myWebView: SC.WebView.extend({ 
    layout: { left: 10, right: 10, top: 10, bottom: 10, border: 1 }, 
    shouldAutoResize: true, // when the iframe loads, resize it to fit the size of its content 
    valueBinding: SC.Binding.oneWay('MyApp.currentUrl') // bind the 'src' of the iframe 
}) 
+0

(附注:我假设shouldAutoResize属性只能在同一原属含量最高的工作,我相信调整大小优雅地失败,在跨域情况下,但这样在最坏的情况你。安全。) – Dave

1

有几种方法可以做到这一点。

假设认为从SC.View延伸,最简单的可能是重写#render方法,并添加iframe的自己:

MyApp.MyView = SC.View.extend({ 
    render: function(context) { 
    context.push("<iframe src='http://google.com' />"); 
    } 
}); 
相关问题