Search
Other Modals questions
Forum

difference on open external links out of modals from J3 to J4 ?

Dirk67's Avatar Dirk67
I am a little lost here ... 😉
(something works on J3 but not on J4)

---------

I created an article with modals and sourcerer that acts as a redirection to youtube videos but the user has to press a button for giving his consent ...

in detail:
if there is a youtube link within any article it links to article ID 2023 with the yt-video-ID as an URL parameter
e.g.:
in J3: hilgermissen.eu/joomla/2023?yt_id=f5gq5LzCqho
in J4: hilgermissen.eu/joomlaclone/unzugeordnet/2023?yt_id=f5gq5LzCqho

then within article ID 2023 the the yt-video-ID is handled with some sourcerer code and then a modals popup is generated with:
{modal url="unzugeordnet/[b]2022[/b]?'.$param.'" width="500" height="500" open="true"}{/modal}
(variable "$param" contains the yt-video-ID)

as you can see: inside the modals popup the article ID 2022 is displayed
and within article ID 2022 (= inside the modals popup) I use the following code for the 2 buttons (with sourcerer):
{source}<button onclick="window.open('', '_self', ''); window.close();" style="padding-left: 10px; padding-right: 10px; margin-left: 50px;" class="btn btn-default">Abbrechen</button>{/source}
resulting in a html output like:
<div>
<a class="btn btn-primary" style="padding-left: 10px; padding-right: 10px;" href="https://youtu.be/f5gq5LzCqho">weiter zu YouTube</a>
<button onclick="window.open('/joomla/', '_self', ''); window.close();" style="padding-left: 10px; padding-right: 10px; margin-left: 50px;" class="btn btn-default">Abbrechen</button>
</div>
the wanted browser behavior is, to stay in the same browser window or tab when the user presses the green consent button.
This works fine on J3: hilgermissen.eu/joomla/2023?yt_id=f5gq5LzCqho
but fails on J4: hilgermissen.eu/joomlaclone/unzugeordnet/2023?yt_id=f5gq5LzCqho
as you can see on J4 the browser tries to open the youtube video within the modals popup, and that fails ...

(same wrong behavior for the window.close() "Abbrechen" -button)

So why is that different browser behavior between J3 and J4,
and how I can overcome that ?

how can I achieve the "wanted browser behavior" that is, to stay in the same browser window or tab when the user presses the green consent button ?

__________________________________________________
modals versions:
on J3: v12.3.5 pro
on J4: v12.3.6-dev2676083 pro
sourcerer versions:
on J3: 9.5.2
on J4: 9.5.2

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
This is because the Joomla 3 version opens articles as inline by default, while the Joomla 4 version opens it in an iframe.

Either set the target of the link in the article to make it open in the parent or _top.
Or make the modal open the article as inline content, which you could do with the help of Articles Anywhere inside the {modalcontent} tags:
docs4.regularlabs.com/modals/content/inline-content
Please post a rating at the Joomla! Extensions Directory
Dirk67's Avatar Dirk67
[edit]: didn't read your answer before writing this:

hmmmm,
I think this occurs because in J4 the modals popup is rendered as an iframe (but not for images ?),
and on J3 the modals popup is rendered without an iframe ?
is that correct ?
can I change that in some backend settings ?

in J4:


in J3:
Peter van Westen's Avatar Peter van Westen ADMIN
See my previous reply.
Please post a rating at the Joomla! Extensions Directory
Dirk67's Avatar Dirk67
set the target of the link in the article to make it open in the parent or _top.
yes thank you,
that works for me with "_parent"
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription