Parent.parent.window.location.href not working

I have a strange problem. I use fancybox in my project, where after clicking on the fancybox link I close it and try to reload the parent window. I am using this code.

<script> parent.$.fancybox.close(); parent.parent.window.location.href = '<?php echo base_url();?>home/job_posting/<?php echo $id ;?>'; </script> 

It works locally, but when a thing trying to run it on a live server does not work. I am using frameworkignign framework and doing this in my controller method.

Please, help.

+4
source share
1 answer

Well, if you are just trying to reload the parent window after closing fancybox, just close fancybox from the open page (how you do it), for example

 <script> parent.$.fancybox.close(); </script> 

... and reload the parent page from yourself by adding an afterClose callback to your own fancybox script, for example

 $(".fancybox").fancybox({ // other API options here afterClose : function() { location.reload(); return; } }); 

On the other hand, if you are not just trying to reload the parent page, but actually trying to redirect to another page, use window.location.pathname if you are using a relative path or window.location.href for the full path.

You can also try self.location.href .

NOTE : afterClose for fancybox v2.x, for fancybox v1.3.4 use onClosed instead.

0
source

Source: https://habr.com/ru/post/1489703/


All Articles