AngularJS iframe跨域打开内容时报错误的解决办法
作者:bea
<iframe id="myFrame" ng-src="{{url}}" width="100%" height="100%" seamless frameborder="0" ></iframe> 打开不同域的内容时报下面的错误: Blocked loading resource from url not allowed by $sceDelegate policy 解决方案: 代码如下: app.config(function($sceD
<iframe id="myFrame" ng-src="{{url}}" width="100%" height="100%" seamless frameborder="0" ></iframe>
打开不同域的内容时报下面的错误:
Blocked loading resource from url not allowed by $sceDelegate policy
解决方案:
代码如下:
app.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
// Allow same origin resource loads.
'self',
// Allow loading from our assets domain. Notice the difference between * and **.
'http://media.w3.org/**']);
});
很简单的方法就解决了angularjs跨域使用iframe的问题,希望大家能够喜欢
有用 | 无用
打开不同域的内容时报下面的错误:
Blocked loading resource from url not allowed by $sceDelegate policy
解决方案:
代码如下:
app.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
// Allow same origin resource loads.
'self',
// Allow loading from our assets domain. Notice the difference between * and **.
'http://media.w3.org/**']);
});
很简单的方法就解决了angularjs跨域使用iframe的问题,希望大家能够喜欢
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- js获取内联样式的方法
- js获取元素外链样式的方法
- jquery复选框多选赋值给文本框的方法
- jQuery+ajax实现动态执行脚本的方法
- javascript将异步校验表单改写为同步表单
- JavaScript中实现sprintf、printf函数
- javascript批量修改文件编码格式的方法
- JavaScript中的包装对象介绍
- 浅谈JSON中stringify 函数、toJosn函数和parse函数
- 浅谈JavaScript Math和Number对象
- js判断一个字符串是否包含一个子串的方法
- javascript中Object使用详解
- JQuery中的事件及动画用法实例
- javascript折半查找详解
- JavaScript数据类型检测代码分享
- 浅谈Javascript中的Function与Object
- javascript实现动态加载CSS
- 使用jQuery实现返回顶部
- SyntaxHighlighter 3.0.83使用笔记