K
K
Kirill Djonua2015-07-05 13:05:11
JavaScript
Kirill Djonua, 2015-07-05 13:05:11

How to display anchor in url when using fancybox?

I have news on the site, they open in popup using fancybox. But the URL does not change. I need to add an anchor to the URL when opening a news item so that I can copy the link. And then, follow this link to open the news. How can I do that?
Fancybox is used like this:

$(".popupbtn, .popuplink").fancybox({
    'overlayColor'		: '#0d4459',
    'overlayOpacity'	: '0.5',
    'margin'			: '70',
    'padding'			: '0',
    onStart		:	function() {
      $(".wrapper").css({
        "-webkit-filter": "blur(10px)"
      });
    },
    onClosed	:	function() {
            $(".wrapper").css({
        "-webkit-filter": "none"
      });
    }
  });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Narek, 2015-07-06
@kdjonua

Before calling the function that opens the fancybox, change the URL of the page to site.com/section/news/#news_1 using the history object. After that, call the function that opens the fanxybox. There you need to find out what is written in the URL after # and, based on this, display the news. Finally, after the page has loaded, call fanxybox's open function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question