Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12747 closed bug (invalid)

scrollTop and scrollLeft binding fails inside POST iframe in IE 9

Reported by: pete.setchell@… Owned by: pete.setchell@…
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:

Description

In our Facebook application running in Facebook's canvas environment the binding of scrollLeft and scrollTop methods fails with an "access denied" message in Internet Explorer 9. This causes completion of element binding to fail and breaks things pretty badly.

Facebook canvas apps exist in an HTTP POSTed cross domain iframe for security reasons to stop Facebook ids and access tokens getting linked and logged in access logs.

Here is the code that fails, starting at line 9348 in jquery version 1.8.2. I've added comments and a try catch around the line that fails, as that allows the function to complete, but obviously does nothing to add back the missing scrollTop / scrollLeft functions that haven't successfully bound.

   // Create scrollLeft and scrollTop methods
    jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
        var top = /Y/.test( prop );

        jQuery.fn[ method ] = function( val ) {
            return jQuery.access( this, function( elem, method, val ) {
                var win = getWindow( elem );

                if ( val === undefined ) {
                    return win ? (prop in win) ? win[ prop ] :
                        win.document.documentElement[ method ] :
                        elem[ method ];
                }

                if ( win ) {
                    win.scrollTo(
                        !top ? val : jQuery( win ).scrollLeft(),
                        top ? val : jQuery( win ).scrollTop()
                    );

                } else {
                    try {
                        // This line fails with "access denied" in an HTTP posted iframe in IE 9
                        elem[ method ] = val;
                    } catch (err) {
                        // do nothing. if this broke or there was an access denied bug for cross browser shenanigans,
                        // at least our element will continue to be created.
                    }
                }
            }, method, val, arguments.length, null );
        };
    });

Change History (2)

comment:1 Changed 7 years ago by mikesherov

Owner: set to pete.setchell@…
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 7 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.