keycloak 翻译/带有链接的消息应在新选项卡中打开

问题描述 投票:0回答:2

我想在 messages_en.properties 中包含一个翻译,其中包含一个链接,该链接会在新选项卡中打开。有办法做到这一点吗?

我已经尝试添加

<a target="_blank" href="http://example.com">Example</a>

<a href="#" onclick='window.open("http://example.com");return false;'>Example</a>

没有成功。

提前致谢

keycloak
2个回答
2
投票

0
投票

Maggie 是对的,但没有提供解决方案。添加此作为明确的答案。

1.首先编辑您想要
target="_blank"
出现的消息/链接并添加 ID
terms

例如

login/messages_en.properties

termsText=<p id="terms"><a href="https://sample-link.de/terms.pdf">Terms</a></p>

2.然后在
resources/js/script.js

中创建一个javascript文件

添加:


(function(window, document, undefined) {

    // code that should be taken care of right away

    window.onload = init;

    function init(){
        // the code to be called when the dom has loaded
        var els = document.getElementById('terms').getElementsByTagName('a');;
        console.log(els)
        for (var i=0; i < els.length; i++) {
            els[i].setAttribute("target", "_blank");

        }
    }

  })(window, document, undefined);


3.更新
theme.properties
并添加:

scripts=js/script.js
© www.soinside.com 2019 - 2024. All rights reserved.