从 Javascript 绑定到 MetroStyle App 中的 InnerHTML
Binding to InnerHTML in MetroStyle App from Javascript
>我有一个 Div 定义为:
<div class="article-content" data-win-bind="innerHTML: content"></div>
并使用具有内容属性的对象绑定到它。
现在我使用外部资源创建的对象,有时 content 属性将具有这样的内容:
"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.
我了解异常以及它发生的原因,但现在我该如何使这项工作?
查看本文档的"动态添加 HTML"部分 您可能需要使用 execUnsafeLocalFunction 来注入您尝试注入的特定 HTML。 另外,请查看这篇博客文章,了解如何创建可在 Metro 风格应用中工作的通用追加函数。
相关文章:
- 使用Express4将数组从Nodejs中的app.js传递到routes/index.js
- 如何使用App.cable.subscriptions.remove删除Rails5中的actioncable频道订阅
- 从 Javascript 绑定到 MetroStyle App 中的 InnerHTML
- ionic框架中的app.js函数冲突
- 如何在express和parse中使用app.get中的app.locals
- AngularJs在app.config中的回调中配置路由
- 如何确保angularjs app.js中的同步加载
- Ionic 2 从子页面修改 app.js 中的变量
- 部分而不是 app.js 中的角度路由定义
- Titanium App (iOS) 中的实时文本区域字符数
- AngularJS:app.run() 中的承诺永远陷入循环
- 使用 app.delete [express.js] 删除 mongo 数据库中的集合
- 为什么我不能从节点和 express.js 中的 app.get 函数中提取回调
- 在 nodejs Express app 中的链接中发送 DELETE 请求
- 关于 Google App Script 中的 Javascript 输出
- 如何在Chrome App中创建一个简单的WebSocket服务器
- 为express app中的JSON请求设置正确的内容类型
- 主干app中的所有事件触发两次.随机发生
- var app =中的第二个括号要求('expression ')()"做的
- 处理Node.Js / Express App中的西里尔字母编码