Ok, so is the intended behaviour to remove the Anvil app and pass all control to this other page?
Actually, my answer is the same regardless
Anvil currently doesnât support opening links in the same tab. It will destroy the running app and thatâs rarely desired behaviour. Also, read Meredyddâs comments here :
I am trying to make anvil applications seamlessly connect to a nav bar of an existing website. As a quick and simple solution I am thinking about connecting the anvil urlâs to the tags after I get the functions I want in the app.
The problem above arose because I want the application to be able to go back to the other pages in the already existing website from the same page.
@david.wylie do you have an example or a code snippet of this? Not necessarily using an iframe, but of âexportingâ an Anvil app or app component to an existing website. Thanks -Ian
Assuming youâre asking if you can export the Anvil app to run on, say, Apache web servers - in short you canât. Anvil apps need their own ecosystem to run in, so unless you have an on-premises version (which they do offer) youâll always be running the code from Anvil servers. Even then I doubt (though I donât know for sure) youâd be able to export the app in the way I think youâre thinking.
Thatâs why you need an iframe - you use the URL of the app as the src to embed it. Itâs as simple as :
Interesting. So you have to run the whole Anvil app in the iframe.
Can the app interact with the rest of the page outside of the iframe, or is the rest of the page static?
For example - if a user logs into their account in the app, in the iframe, can a button text in the header, outside of the iframe, change from âloginâ to âlogoutâ?
âŚand do, say, the Anvil buttons take on the CSS button style that is for the rest of the site, or is their style determined by the Anvil stylesheet?
Not by default, no. The iframe is a self contained page.
A lot of what you are asking might be technically possible with some serious experimentation, but in all honesty (and in my opinion) you are starting to go so far off piste that even if you did get it working it would be very fragile.
If you really want to get the two apps interacting, I would suggest building an API in the parent page (equivalent to an Anvil HTTP endpoint). That way you can call it from Anvil.