IE7 inline content problem

284 views
Skip to first unread message

Joaquin

unread,
Jan 5, 2012, 9:59:50 AM1/5/12
to fancybox
I've found that fancybox is not working for inline content on IE7.

The problem is that IE7 sends the full address to the href attribute
instead of just "#blabla" so href value becomes "http://domain/any-
more-stuff#blabla".

I've fixed this problem by inserting these lines on line 127 of
jquery.fancybox-1.3.4.js:

} else if (href.indexOf("#") > 0) {
aux1 = href.substr(0,href.indexOf('#'));

if (window.location.href.indexOf('#') >= 0) {
aux2 =
window.location.href.substr(0,window.location.href.indexOf('#'));
} else {
aux2 = window.location.href;
}
if (aux1 == aux2){
type = 'inline';
} else {
alert(aux1 + " " + aux2);
type = 'ajax';
}

// here continues the current script.

It would be nice to have this issue fixed for future versions so I
leave it here to fancybox developers.

JFK

unread,
Jan 5, 2012, 3:30:50 PM1/5/12
to fancybox
I have IE7 and the inline type works just fine out of the box

Joaquin

unread,
Jan 10, 2012, 8:22:20 AM1/10/12
to fancybox
I've went a little far and the problem is due to content loaded
through ajax. somehow in IE7 anchors that are loaded through ajax (I'm
using asp.net, mvc and jquery) that link to inline contents get their
href attribute set to full address instead of just #something so the
assumption that the # is on index = 0 is false and fancybox is
processing them as a content to be loaded through an ajax call instead
of inline. My patch do verify if the linked address is the same than
the location then it's inline content else it should be loaded through
ajax.

JFK

unread,
Jan 10, 2012, 9:10:17 PM1/10/12
to fancybox
asp.net?
that explain everything

... well, seriously I am just being ironic ... I have little
experience with asp.net, but for sure is not a fancybox issue

Tim

unread,
Feb 10, 2012, 11:32:36 AM2/10/12
to fancybox
I'm going to have to disagree with you, JFK. I'm working in a Perl
environment that makes heavy use of iFrames (:/) and AJAX calls, and I
was having this SAME EXACT issue as the OP. I was trying out the
Inline-style lightbox and everything worked beautifully with FF,
Chrome, and IE8, but it fell apart in IE7; instead of loading the
contents of the hidden DIV it would reload the entire page in the
popup... presumably because IE7 was treating the internal link
(#message) as an absolute link (myplaceofemployment.com/
iframesAreAwful/OMGLOL.html#message). I'd assume this error makes
lighbox implement an AJAX-style lightbox instead.

I used the code from the first post to replace the last else statement
( else { type = 'ajax';} ) at line 125 and everything works EXCELLENT.

Thank you so much to the OP. You made my hours (days really) of
struggling worth it.

-Tim

On Jan 10, 9:10 pm, JFK <jfk.d...@gmail.com> wrote:
> asp.net?
> that explain everything
>
> ... well, seriously I am just being ironic ... I have little
> experience with asp.net, but for sure is not a fancybox issue
>
> On Jan 10, 5:22 am, Joaquin <jvei...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I've went a little far and the problem is due to content loaded
> > through ajax. somehow inIE7anchors that are loaded through ajax (I'm
> > using asp.net, mvc and jquery) that link to inline contents get their
> > href attribute set to full address instead of just #something so the
> > assumption that the # is on index = 0 is false and fancybox is
> > processing them as a content to be loaded through an ajax call instead
> > of inline.  My patch do verify if the linked address is the same than
> > the location then it's inline content else it should be loaded through
> > ajax.
>
> > On Jan 5, 5:30 pm, JFK <jfk.d...@gmail.com> wrote:
>
> > > I haveIE7and the inline type works just fine out of the box
>
> > > On Jan 5, 6:59 am, Joaquin <jvei...@gmail.com> wrote:
>
> > > > I've found that fancybox is not working for inline content onIE7.
>
> > > > The problem is thatIE7sends the full address to the href attribute

JFK

unread,
Feb 11, 2012, 7:56:30 PM2/11/12
to fancybox
@tim: I guess you have the right to disagree, and I appreciate it
because it makes me go and try to learn more

Joaquin is totally right when he says "the problem with IE7 is due to
anchors that are loaded through ajax", which it makes sense since
those are not part of the document when the DOM is ready, hence they
cannot use canonical paths but absolute. I guess in that way IE7 is a
smarter browser to make that distinction.

IF anchors are hard-coded into the document, then IE7 will always
return the hash value only. In that case fancybox type=inline will
work out-of-the-box.

Joaquin's patch applies for the combination of ajaxed anchors AND
inline content only. Hats off !!

IF the anchors are hard-coded into the html document, then IE7 will
return the hash element only.

Tim

unread,
Feb 18, 2012, 10:20:24 AM2/18/12
to fancybox
@JFK: Even though this error occurs in a fairly specific use-case,
it's still a legitimate use-case that FancyBox needs to account for.
I'm just really glad that the OP created a solution for this... :)
Reply all
Reply to author
Forward
0 new messages