用于Angular应用程序的iframe无法正常工作,但仅适用于移动设备

时间:2018-02-09 06:53:35

标签: ios angularjs django iframe

我有一个带Django后端的AngularJS应用程序。我将iframe插入到另一个网站上,应用程序在桌面上以及Chrome调试器移动菜单上运行良好。它也可以在访问网站时在移动设备上运行。仅当我在移动设备上访问我的Angular应用程序的iframe网站时,它才会运行。它加载了html,但是从我们后端检索的数据都没有填充iframe中的页面。完全不知所措。我知道它不是我的代码,因为它适用于所有其他版本。这可能是一个iframe问题,还是iOS问题?

更新

它也适用于我的三星平板电脑,因此它似乎只是一个iOS问题

iframe

<iframe src="http://66.175.220.49/dealer-swipe/#/3087" scrolling="auto" align="center" frameBorder="0" height="500px" width="100%" class="myIframe"></iframe>

更新2 我检查了服务器上的日志,并注意到有时当Angular进行AJAX调用时会出现一些OSWrite错误。

ERROR 2018-02-09 21:52:21,955 ajax_views.py dealer_info 10 GETTING THE DEALER ...
ERROR 2018-02-09 21:52:21,959 ajax_views.py dealer_info 28 DEALER 3087 SUCCESS
[pid: 11719|app: 0|req: 34/34] 107.77.169.5 () {48 vars in 917 bytes} [Fri Feb  9 21:52:21 2018] POST /dealer/3087 => generated 402 bytes in 5 msecs (HTTP/1.1 200) 2 headers in 80 bytes (1 switches on core 0)
ERROR 2018-02-09 21:52:22,103 ajax_views.py get_filters 13 GETTING FILTERS
ERROR 2018-02-09 21:52:24,394 ajax_views.py get_filters 113 GET FILTERS SUCCESS
Fri Feb  9 21:52:24 2018 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /dswipe/filters/ (ip 107.77.169.5) !!!
Fri Feb  9 21:52:24 2018 - uwsgi_response_write_headers_do(): Broken pipe [core/writer.c line 216]
OSError: write error
[pid: 11719|app: 0|req: 35/35] 107.77.169.5 () {50 vars in 1008 bytes} [Fri Feb  9 21:52:22 2018] POST /dswipe/filters/ => generated 0 bytes in 2293 msecs (HTTP/1.1 200) 2 headers in 0 bytes (0 switches on core 0)
Fri Feb  9 21:52:24 2018 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /dealer-swipe/ (ip 107.77.169.5) !!!
Fri Feb  9 21:52:24 2018 - uwsgi_response_write_headers_do(): Broken pipe [core/writer.c line 216]
OSError: write error
[pid: 11719|app: 0|req: 36/36] 107.77.169.5 () {42 vars in 822 bytes} [Fri Feb  9 21:52:24 2018] GET /dealer-swipe/ => generated 0 bytes in 3 msecs (HTTP/1.1 200) 4 headers in 0 bytes (0 switches on core 0)
ERROR 2018-02-09 21:52:24,400 ajax_views.py next_vehicle 403 PREPARING TO GET NEXT VEHICLE ...
3087
Tracy Langston Ford - Lincoln - Mercury, LLC
ERROR 2018-02-09 21:52:24,427 ajax_views.py next_vehicle 485 GETTING NEXT VEHICLE SUCCESS !
Fri Feb  9 21:52:24 2018 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /account/next_vehicle/ (ip 107.77.169.5) !!!
Fri Feb  9 21:52:24 2018 - uwsgi_response_write_headers_do(): Broken pipe [core/writer.c line 216]
OSError: write error

1 个答案:

答案 0 :(得分:4)

尝试避免将网址直接绑定到iframe,您可以尝试将其放入控制器中。 trustAsResourceUrl 是您需要使用的方法

<强> HTML

<强> <iframe ng-src="{{trustSrc(object.url)}}"></iframe>

并在

<强>控制器

 $scope.trustSrc = function(src) {
       return $sce.trustAsResourceUrl(src);
  }