Angular JS:iframe 在 Firefox 和 IE 11 中不起作用 [英] Angular JS : iframe not working in Firefox and IE 11

查看:29
本文介绍了Angular JS:iframe 在 Firefox 和 IE 11 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 uibmodal 中有一个 iframe,我向它提供了一个静态 HTML 路径(在同一个域中).该 URL 在 Safari、Chrome 和 iOS 设备中正常工作.但是,它不会在 Firefox 和 IE11 中加载.

I'm having an iframe in an uibmodal, to which I'm providing a static HTML path (in the same domain). The URL works correctly in Safari, Chrome and iOS Devices. However, it doesn't load in Firefox and IE11.

经过一些研究,我知道这是因为 ui-router 无法访问我提供的相对 URL.这是我遇到的一个类似问题 (link),但是我不知道我应该如何修复它.

After doing some research I got to know that it's because of ui-router that it's not able to go to the relative URL which I'm providing. Here's a similar question which I came across (link) , however I don’t know how I should go about fixing it.

我尝试使用 $sce.trustAsResourceUrl() 解析 URL,甚至通过提供绝对路径,例如.http://localhost:3000/#mySamplePage.它仍然可以在 Chrome 中加载,但无法在 Firefox 和 IE11 上加载.另外需要注意的是,控制台中没有任何错误.

I’ve tried to parse the URL using $sce.trustAsResourceUrl(), and even by giving an absolute path e.g.. http://localhost:3000/#mySamplePage. It still loads in Chrome but fails to load on Firefox and IE11. Also the thing to note is that there aren’t any errors in the console.

我使用的是 angular ui-router 版本 0.2.18 和 angular 1.5.

I’m using angular ui-router version 0.2.18 and angular 1.5.

请分享您的宝贵意见.

谢谢!

推荐答案

我遇到了同样的问题并且能够解决它(在 Angular.js、iframes 和 Firefox).iframe 需要知道 FF 和 IE 中的默认页面.我们是一个托管 angular 应用程序的 mvc 应用程序,因此我们的 iframe 的 url 需要默认控制器:

I had the same issue and was able to solve it (with help from Angular.js, iframes and Firefox). The iframe needs to know the default page in FF and IE. Ours is an mvc app hosting the angular app so the url for our iframe needed the default controller:

http://localhost:8000/mvc/Controller/#/mySamplePage

这篇关于Angular JS:iframe 在 Firefox 和 IE 11 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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