Skip to main content

Bug Tracker

Side navigation

#12747 closed bug (invalid)

Opened October 16, 2012 05:21PM UTC

Closed November 03, 2012 08:51AM UTC

scrollTop and scrollLeft binding fails inside POST iframe in IE 9

Reported by: pete.setchell@gmail.com Owned by: pete.setchell@gmail.com
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 );
        };
    });
Attachments (0)
Change History (2)

Changed October 19, 2012 02:40PM UTC by mikesherov comment:1

owner: → pete.setchell@gmail.com
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.

Changed November 03, 2012 08:51AM UTC by trac-o-bot comment:2

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!