skip to Main Content

Please see jQuery source code: https://code.jquery.com/jquery-2.1.3.js
If we search for text "<iframe" then we can see below function:

function defaultDisplay( nodeName ) {
    var doc = document,
        display = elemdisplay[ nodeName ];

    if ( !display ) {
        display = actualDisplay( nodeName, doc );

        // If the simple way fails, read from inside an iframe
        if ( display === "none" || !display ) {

            // Use the already-created iframe if possible
            iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );

            // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
            doc = iframe[ 0 ].contentDocument;

            // Support: IE
            doc.write();
            doc.close();

            display = actualDisplay( nodeName, doc );
            iframe.detach();
        }

        // Store the correct default display
        elemdisplay[ nodeName ] = display;
    }

    return display;
}

This works fine, however, our Web firewall blocks this file because of suspecting possible iframe injection. It seems the function is creating iframe element and appends the element. Later, it uses the iframe to get the display value.

Any workaround/alternatives of using iframe so that we can replace the line which reads:

iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );

Kindly note that I cannot change the firewall provider. Further, this is on AngularJS 1.4.5, does it have any dependencies on jQuery version? All I know is that AngularJS 1.4.5 requires jQuery, but not sure which version.

Has anybody used AngularJS 1.4.5 with latest jQuery version?

2

Answers


  1. Chosen as BEST ANSWER

    Here is what I ended up with:

    //iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
    
    if (!iframe){
     iframe = document.createElement("iframe");
     iframe.frameBorder = iframe.width = iframe.height = 0;
    }
    doc.documentElement.appendChild(iframe);
    doc = iframe[0].contentDocument;
    
    //rest of the code
    
    

    This way, now the proxy server isn't showing any error message as text "<iframe" is not found and we are creating by other means of JS.


  2. If you check the Angular JS FAQ, there’s a question about the use of jQuery in Angular JS 1.4.5 (emphasis is mine)

    Does AngularJS use the jQuery library?

    Yes, Angular can use jQuery if it’s present in your app when the application is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

    Angular 1.3 only supports jQuery 2.1 or above. jQuery 1.7 and newer might work correctly with Angular but we don’t guarantee that.

    As you can see from this, there is no hard dependency upon jQuery at all and Angular JS will use it’s own version of jQuery, jQLite.

    You should be okay to completely remove jQuery from your Angular JS page(s) assuming it’s not being used anywhere else.

    Unfortunately it’s not clear whether the "supports jQuery 2.1 or above" includes major versions.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search