I'm using 'fancy box
' and I'm trying to change my url to be
the url of the fancy box
, so I try to use History.pushState()
.
but it makes error
The error:
Uncaught SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'about:blank' cannot be created in a document with origin 'http://localhost:28587'
My code:
var _url = window.location.href; setInterval(function () { if (($(".fancybox-iframe").length > 0)) { if(window.location.href != $('.fancybox-iframe').contents().get(0).location.href) { history.pushState(null, null, $('.fancybox-iframe').contents().get(0).location.href); } } else { if(window.location.href != _url) { history.pushState(null,null, _url); } } }, 80);
I'd search it and didn't find an answer, please help me
or Suggest me better solution for doing that.
(I found this:Javascript history.PushState not working? but I didnt understand what wrong in my code from the answer)
Edit:
and another problem is that when i press "back" in browser the url is change but not actually loaded, why??