How to close Fancybox window by clicking on a text link?

2,369 views
Skip to first unread message

Webzine

unread,
Feb 3, 2012, 2:58:07 PM2/3/12
to fanc...@googlegroups.com

How to close Fancybox window by clicking on a text link "Close", and
place this link to the bottom right corner?

Thank you.

--
http://www.fastmail.fm - IMAP accessible web-mail

JFK

unread,
Feb 3, 2012, 7:22:29 PM2/3/12
to fancybox
<a href="javascript:$.fancybox.close()">close</a>

if closing from iframe, then
<a href="javascript:parent.$.fancybox.close()">close</a>

Webzine

unread,
Feb 4, 2012, 7:49:10 AM2/4/12
to fanc...@googlegroups.com
Thanks for tips.
Where's the place in jquery.fancybox-1.3.4 CSS to insert this code?

--

On Fri, Feb 3, 2012, at 04:22 PM, JFK wrote:
> <a href="javascript:$.fancybox.close()">close</a>
>
> if closing from iframe, then
> <a href="javascript:parent.$.fancybox.close()">close</a>
>
> On Feb 3, 11:58 am, Webzine <techla...@eml.cc> wrote:
> > How to close Fancybox window by clicking on a text link "Close", and
> > place this link to the bottom right corner?
> >
> > Thank you.
> >

>
> --
> You received this message because you are subscribed to the Google Groups
> "fancybox" group.
> To post to this group, send email to fanc...@googlegroups.com.
> To unsubscribe from this group, send email to
> fancybox+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/fancybox?hl=en.
>

--
http://www.fastmail.fm - Access your email from home and the web

Webzine

unread,
Feb 4, 2012, 8:56:42 AM2/4/12
to fanc...@googlegroups.com
Specifically, I need this close link for Fancybox-1.3.4 which used in
Prestashop.
How to implement the code samples in Fancybox, which is Prestashop image
viewer?

<a href="javascript:$.fancybox.close()">close</a>

<a href="javascript:;" onclick="$.fancybox.close();"><img
src="/data/closelabel.gif" /></a>


--

On Fri, Feb 3, 2012, at 04:22 PM, JFK wrote:

> --
> You received this message because you are subscribed to the Google Groups
> "fancybox" group.
> To post to this group, send email to fanc...@googlegroups.com.
> To unsubscribe from this group, send email to
> fancybox+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/fancybox?hl=en.
>

--
http://www.fastmail.fm - mmm... Fastmail...

JFK

unread,
Feb 4, 2012, 2:50:49 PM2/4/12
to fancybox
I guess any would work but you also can try
<a href="javascript:$.fancybox.close();"><img src="/data/
closelabel.gif" /></a>

On Feb 4, 5:56 am, Webzine <techla...@eml.cc> wrote:
> Specifically, I need this close link for Fancybox-1.3.4 which used in
> Prestashop.
> How to implement the code samples in Fancybox, which is Prestashop image
> viewer?
>
> <a href="javascript:$.fancybox.close()">close</a>
> <a href="javascript:;" onclick="$.fancybox.close();"><img
> src="/data/closelabel.gif" /></a>
>
> --
>
>
>
>
>
>
>
>
>
> On Fri, Feb 3, 2012, at 04:22 PM, JFK wrote:
> > <a href="javascript:$.fancybox.close()">close</a>
>
> > if closing from iframe, then
> > <a href="javascript:parent.$.fancybox.close()">close</a>
>
> > On Feb 3, 11:58 am, Webzine <techla...@eml.cc> wrote:
> > > How to close Fancybox window by clicking on a text link "Close", and
> > > place this link to the bottom right corner?
>
> > > Thank you.
>
> > > --http://www.fastmail.fm-IMAP accessible web-mail

Webzine

unread,
Feb 4, 2012, 3:22:57 PM2/4/12
to fanc...@googlegroups.com
the question is where specifically to add this code in Fancybox? I want
completely replace default #fancybox-close button with text link.

thank you.
--

On Sat, Feb 4, 2012, at 11:50 AM, JFK wrote:
> I guess any would work but you also can try
> <a href="javascript:$.fancybox.close();"><img src="/data/
> closelabel.gif" /></a>
>
> On Feb 4, 5:56 am, Webzine <techla...@eml.cc> wrote:
> > Specifically, I need this close link for Fancybox-1.3.4 which used in
> > Prestashop.
> > How to implement the code samples in Fancybox, which is Prestashop image
> > viewer?
> >
> > <a href="javascript:$.fancybox.close()">close</a>
> > <a href="javascript:;" onclick="$.fancybox.close();"><img
> > src="/data/closelabel.gif" /></a>
> >
> > --
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Fri, Feb 3, 2012, at 04:22 PM, JFK wrote:
> > > <a href="javascript:$.fancybox.close()">close</a>
> >
> > > if closing from iframe, then
> > > <a href="javascript:parent.$.fancybox.close()">close</a>
> >
> > > On Feb 3, 11:58 am, Webzine <techla...@eml.cc> wrote:
> > > > How to close Fancybox window by clicking on a text link "Close", and
> > > > place this link to the bottom right corner?
> >
> > > > Thank you.
> >

--
http://www.fastmail.fm - Accessible with your email software
or over the web

JFK

unread,
Feb 5, 2012, 2:59:43 AM2/5/12
to fancybox
you add the code in your page .... don't need to mess with the css or
js fancybox files

create your custom script like that
$("a.fancybox").fancybox({
'showCloseButton' : false
});
(the option hides the default close button)

then call your content with a link like
<a href="#mycontent" class="fancybox">open fancybox>/a>

inside of such content add the closing code
<a href="javascript:$.fancybox.close();"><img src="/data/
closelabel.gif" /></a>

if you have further questions, be sure you read and understand
http://fancybox.net/howto
also it does worth to read the FAQs
> --http://www.fastmail.fm- Accessible with your email software
>                           or over the web

Webzine

unread,
Feb 5, 2012, 10:20:28 AM2/5/12
to fanc...@googlegroups.com
I understand, but it's more difficult to implement this way as my
content is dynamically generated by Prestashop PHP files.
It seems more easy will be to add the closing code to Fancybox popup via
titleFormat option using custom html, API say the titleFormat key calls
customize title area, where possible set any html or custom navigation.
I want find way to insert 'close' link under the image via titleFormat
option (custom javascript), title itself can be blank, no required, only
Close link.


dont know how to modify this

function formatTitle(title, currentArray, currentIndex, currentOpts) {
return '<div id="tip7-title"><span><a
href="javascript:$.fancybox.close()">close</a></span>' + (title &&
title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' +
(currentIndex + 1) + ' of ' + currentArray.length + '</div>';
}


or this


$(document).ready(function(){
$("a.myfancytitle").fancybox({
'padding': 0,
'titlePosition': 'over',
'titleFormat' : function() {
return '<span id="fancybox-title-over">'+this.href+'</span>';
}
});
});


> --
> You received this message because you are subscribed to the Google Groups
> "fancybox" group.
> To post to this group, send email to fanc...@googlegroups.com.
> To unsubscribe from this group, send email to
> fancybox+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/fancybox?hl=en.
>

--
http://www.fastmail.fm - Choose from over 50 domains or use your own

Webzine

unread,
Feb 7, 2012, 11:06:19 AM2/7/12
to fanc...@googlegroups.com
In order to enable custom "close" link option, the following code was
added to the end of Fancybox script:


function formatTitle(title, currentArray, currentIndex, currentOpts)
{

return '<div id="tip7-title"><span><a
href="javascript:$.fancybox.close()">close</a></span>' + '</div>';

}

$(".tip7").fancybox({
'showCloseButton' : false,
'titlePosition' : 'inside',
'titleFormat' : formatTitle
});

But it not work: not show 'Close' link below the image, and not disable
default ugly CloseButton.
How to make it work? I don't want use additional javascripts scripts as
it bad practice.

--

Reply all
Reply to author
Forward
0 new messages