We can detect iFrame source change with onload event. I tried to create iFrame onLoad event with directive, but that is not working. So here I am sharing the solution which is working. Real height of the iFrame document can be detected by iFrameID.contentWindow.document.body.scrollHeight

Calling AngularJS function from javascript 

JavaScript onload event for iframe works good. Here we are going to call AngularJS function from javascript function. To call AngularJS function, we need to get scope of the element. 
var ifrm = document.getElementById('myIframe');
angular.element(ifrm).scope().onIframeLoad(ifrm);

Script

$scope.onIframeLoad = function(iFrameID) {
    if (iFrameID) {
        // here you can make the height, I delete it first, then I make it again
        iFrameID.height = "";
        iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight+ "px";
    }
};

3 comments:

  1. Set iFrame height as per source change with angularJS. Things which are telling you more for the height that whole tells how to bring changing in source where it is perfect to make dissertation writing service. I know everything for these changes which are important that whole are only for you.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Many readers were worried about their iframe, but now they are happy because they got detailed content, and they can solve their issues related to iframe usage easily. Dissertation writing services.

    ReplyDelete

Blogroll

Popular Posts