2012-08-12 15 views
2

我有一個DIV定義爲:綁定到的innerHTML在MetroStyle應用程序從Javascript

<div class="article-content" data-win-bind="innerHTML: content"></div> 

和IM結合它與具有內容屬性的對象。

現在我創建了使用外部資源,有時內容屬性的對象將包含內容是這樣的:

"some text <iframe width="560" height="315" src="youtubelink" frameborder="0" allowfullscreen></iframe>" 

此拋出異常:

Unable to add dynamic content. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement. 

我明白例外,爲什麼它的發生,但現在我該如何做這項工作?

+1

按照錯誤消息的建議,如果瀏覽器支持它。我會擔心,這會去掉'