I've thought this through a bit better than the last time (sorry... 🤔 ) and tried many solutions but am stuck:
I have created a modal within a page, which works perfectly well. The modal displays a web page which links to a second one. On this second page, I have tried to create a "Close" button using on-click="parent.jQuery.rl_modals.close();" or just on-click="jQuery.rl_modals.close();" but could not get the button to work.
I'd like to follow up with the "Close modal from a new page within the modal" question if I may.
I am using a modal as an iframe to a page on the same site. I'd like to be able to initiate a close from within the iframe but I'm running into origin errors DOMExcption blocked with origin https://same site ...from accessing a cross-origin frame.
I get this with the Close attempt using parent.jQuery.rl_modals.close(); from the inspect console while in the context of the iframe. I don't think it's "illegal" to call the parent when the parent is from the same origin as your iframe modal is.
Any recommendations on how to do this? Your close button "x" is in the parent frame and I can call jQuery.rl_modals.close(); from the parent context in console of inspect successfully.
It's a contact page and I would like to initiate a close on completion of the submission of the form
In both cases you are not using an iframe, so it should be:
jQuery.rl_modals.close()
The reason it isn't working is because your template is loading another jquery file, after Joomla's own jquery file and Modals has been loaded.
That overrides the jQuery object and causes issues.
So the solution: remove the lines in your template file that are loading the jQuery scripts.
Lines 64 and 65 in the HTML output of that page you linked to.
Please try to replicate the issue on a page where you are loading the Modals stuff normally. Preferably first using the Joomla core template.
Now you are mucking around again with loading an external jquery file and commenting out the Modals scripts it needs to function.
Sorry I was trying to troubleshoot it. It seems to work on a blank page using Protostar but not with the site template. Looks like it loading everything to me.