Cakephp3 usinng javascript doesnt work in iframe

Hi, in cakephp2 I used the below code to exit out of an iframe and it worked fine but not in cakephp3. Running the below code from a file works fine but inside an iframe it doesnt load/work. How can I get this to work inside an iframe? I have a few hours with fiddling around but it just doesnt work.
All i need to do is call a view and redirect to the below website. This code runs inside an iframe but cant redirect out of the iframe.

    = '';

Where did you put this script tag?

The script tag is in the view as is. There was nothing else in the file. I also tried putting the code in an imported js file on a document ready event and nothing in the view. I cant get js to render,

tryed with script block?

    $(document).ready(function() { = "";
', ['block' => true]);

yes it works but the script block needed to be in the view