search

Home  >  Q&A  >  body text

angular.js - [angular] After embedding an Iframe with an anchor, the Iframe does not display normally when loading the page for the first time.

There is an angular project that needs to embed an iframe and link to another subdomain name. This address is anchored, and the url is as follows:

http://example.com/index.html?uk=tester#/zone

The code is as follows:
Html:

<iframe id="user" ng-src="{{myurl}}"></iframe>

JS:

angular.module('myapp').controller('DemoCtrl', function ($scope, $sce, $cookies, $http) {
    ...
    var url = "http://example.com" + "?uk=" + $cookies.get("uk") + "#/zone";
    $scope.myurl= $sce.trustAsResourceUrl(url);
});

The strange thing is that when this page is loaded for the first time, the iframe is displayed as blank (there is no problem with the iframe src). After refreshing it again, it can be displayed normally.

If the iframe src is an address without an anchor, such as embedding www.baidu.com, there will be no problem when loading the page for the first time.

So, the problem should be here at the anchor point "#/zone".

Does anyone know why? How to solve this problem! Thank you very much!

PHP中文网PHP中文网2802 days ago822

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-15 17:05:35

    Have the original poster solved the problem, please ask

    reply
    0
  • Cancelreply