我想在 messages_en.properties 中包含一个翻译,其中包含一个链接,该链接会在新选项卡中打开。有办法做到这一点吗?
我已经尝试添加
<a target="_blank" href="http://example.com">Example</a>
和
<a href="#" onclick='window.open("http://example.com");return false;'>Example</a>
没有成功。
提前致谢
Maggie 是对的,但没有提供解决方案。添加此作为明确的答案。
target="_blank"
出现的消息/链接并添加 ID terms
。例如
login/messages_en.properties
:
termsText=<p id="terms"><a href="https://sample-link.de/terms.pdf">Terms</a></p>
resources/js/script.js
添加:
(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);
theme.properties
并添加:scripts=js/script.js