Skip to content

Commit

Permalink
Merge pull request #1356 from axonivy-market/feature/IVYPORTAL-18210-…
Browse files Browse the repository at this point in the history
…SecurityError-happens-when-reloading-with-iframe-inside-external-page-widget

feature/IVYPORTAL-18210-SecurityError-happens-when-reloading-with-ifr…
  • Loading branch information
chnam-axonivy authored Jan 7, 2025
2 parents f07d545 + 08b306b commit fa227ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<p:commandLink id="theme-switcher" disabled="#{!themeBean.enableSwitchThemeButton}" ariaLabel="#{ivy.cms.co('/ch.ivy.addon.portalkit.ui.jsf/applicationMenuHeader/ThemeSwitcher')}" global="false"
onclick="PrimeFaces.FreyaConfigurator.changeLayout('ivy', '#{ivyFreyaTheme.mode == 'light' ? 'dark' : 'light'}');Portal.changePortalVariableTheme('#{ivyFreyaTheme.mode == 'light' ? 'dark' : 'light'}');">
<i class="topbar-icon pi pi-#{ivyFreyaTheme.mode == 'light' ? 'moon' : 'sun'}" />
<p:ajax onstart="PrimeFaces.FreyaConfigurator.beforeResourceChange();" oncomplete="reloadIframes();"
<p:ajax onstart="PrimeFaces.FreyaConfigurator.beforeResourceChange();" oncomplete="reloadIframesInsidePortalAIChat();"
listener="#{themeBean.toggleTheme()}" update="theme-switcher #{p:resolveFirstComponentWithId('content-container:iFrame', view).clientId}" />
</p:commandLink>
</li>
Expand Down
14 changes: 9 additions & 5 deletions AxonIvyPortal/portal/webContent/resources/js/portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,15 @@ function getWidgetVarById(id) {
}


function reloadIframes() {
var iframes = document.querySelectorAll('iframe');
iframes.forEach(function(iframe) {
iframe.contentWindow.location.reload();
});
function reloadIframesInsidePortalAIChat() {
var iframeInsidePortalAIChat = document.getElementById('iFrame');
if (iframeInsidePortalAIChat) {
var contentInsideIframe = iframeInsidePortalAIChat.contentDocument || iframeInsidePortalAIChat.contentWindow.document;
var iframes = contentInsideIframe.getElementsByClassName('message-iframe');
for (let item of iframes) {
item.src = item.src;
}
}
}

function handleKeyDown(event) {
Expand Down

0 comments on commit fa227ca

Please sign in to comment.