oveleon / contao-cookiebar

Cookie bar for the Contao Open Source CMS
GNU Affero General Public License v3.0
58 stars 24 forks source link

IFrame attributes only taken into consideration on first unblock #221

Closed drum-und-dran closed 1 month ago

drum-und-dran commented 1 month ago

Prerequisites

Please select the topic(s) that most closely match your concern

Other (Specify within description)

Description

Videos integrated in Contao via the Youtube content element can only be viewed in full screen mode the first time after you have agreed to this in the overlay or inline blocker. After a reload or revisit of the page this is no longer possible (full screen is not available).

Relevant log output

No response

zoglo commented 1 month ago

This happens because the iframe source can't be modified once the inner iframe detects it. The attributes within the iframe can't be detected due to another src.

Can you confirm that this change will work @drum-und-dran ?

Template: ccb_element_blocker.html5

https://github.com/oveleon/contao-cookiebar/blob/fde4a2316ddb8fd698e40368ba279584df07e39a/contao/templates/cookiebar/ccb_element_blocker.html5#L72-L77

You have to add this one line

if(parent.cookiebar.issetCookie(<?=$this->id?>)){
    const decoder = document.createElement('textarea');
    decoder.innerHTML = '<?=$this->redirect?>';
+   window.frameElement.src = '<?=$this->redirect?>';
    window.location.href = decoder.value;
}

(Yeah, the other window.location.href is needed as well, otherwise you'd see the "unblock" page and then it vanishes)

zoglo commented 1 month ago

@drum-und-dran I hope you have some time to see if this solves your problem :) Feel free to open a pull request against the 1.x branch if it does ;)

drum-und-dran commented 2 weeks ago

@drum-und-dran I hope you have some time to see if this solves your problem :) Feel free to open a pull request against the 1.x branch if it does ;)

Yes, thank you very much! Everything works as it should.