i am using iframe to load up a webpage inside one of my view for ionic.
<iframe name="siteFrame" id="siteFrame" src="www.example.com" style="width:100%; height:100%" height="100%" ></iframe>
what happens is that when the backbutton is pressed instead of going back to the previous page in the iframe the app exists.
i cannot detect the current href of the iframe as the cross domain security issues prevents me.
what i want to do is that the phones back button should work on the iframe but when the iframe is at it's home page the backbutton should work for the views then
How can this be done?
The problem is that Cordova is linking the back button to the webviews back command, and if it's not going back in the iframe, the iframe is never forming part of your webviews history (which it should be, but I could be wrong - have you changed how your history is working at all?)
What you could try is capturing the back action yourself, and using it to instruct the iframe to go back a page.
One method for this is document.addEventListener("backbutton", yourFunctionHere, false);
, where you then instruct the iframe to go back within the yourFunctionHere
call using iframe.contentWindow.history.back();
I haven't tested any of the above but hopefully this should give you a starting point you can work off. However given you're working cross-domain, it's possible access to even the back() command is restricted, in which case you're probably out of luck.
You can find the relevant Cordova documentation here, just in case: https://cordova.apache.org/docs/en/edge/cordova_events_events.md.html