Make link iframe to app

Hi. I have added an iframe to a F7 page. I want to open a page in app when a user click button in the iframe. I tried foloowing code but it dosen’t work. How can I do?

<a href="/rayon/" target="_parent" class="btn btn-primary" id="btnClose" style="background-color: #ff6600; width:100%">Main Page</a>

This code is in the iframe.

iframe doesn’t really know about F7
try this:

<a onclick="parent.app.views.current.router.navigate('/rayon/')">Main Page</a>

that is the easy way
which i personally don’t really like

Any need to set target?

Sounds like a not good idea. Why do you this? If iframe has a different origin I don’t believe it is easily possible

Because I realized payment process in an iframe. when the payment process finish, a result message and an “OK” button appears in the iframe. If user clicks OK button, I want open app’s home page without iframe.

vladimir was pretty clear
that is a SS job

if you insist (hope you dont)
go to https://framework7.io/kitchen-sink/core/
open console and type this:

var url='https://framework7.io/kitchen-sink/core/';
var iframe=Dom7('<iframe src="'+url+'" width="400" height="400"></iframe>');
Dom7('.page-content').prepend(iframe);

now, wait for iframe to be load
and type this:

var code="parent.app.views.current.router.navigate('/about/')";
Dom7(iframe[0].contentWindow.document).find('.page-content').attr('onclick',code);

now click on your iframe and the “parent” will load “about” page

I tried this solution but I have an error when clik the button.

Uncaught DOMException: Blocked a frame with origin “null” from accessing a cross-origin frame.

my code works only on same-origin

yours is definitely a diff-origin
you can’t do that