【发布时间】:2018-04-18 14:02:51
【问题描述】:
点击<p:commandLink/>(primefaces 库的)后需要打开或重定向到多个页面。
有一个包含网址的列表。我已经试过了:
List<String> newUrlsList = returnNewUrlsList(oldUrl);
for (int i = 0; i < newUrlsList.size(); i++) {
//Executes the redirect for each of the elements in the list
//In every url, in the case of the method returnNewUrlsList() has encountered more than one URL
FacesContext.getCurrentInstance().getExternalContext().redirect(newUrlsList.get(i));
}
但只打开第一个 URL (i=0)。
除此之外,我还尝试了 javascript,如下所示:
<a href="#" class="openPages"> Link </a>
跑步:
<script type="text/javascript">
$('a.openPages').click(function (e) {
e.preventDefault();
window.open('http://www.google.com.br');
window.open('http://www.google.com.br');
window.open('http://www.google.com.br');
window.open('http://www.google.com.br');
window.open('http://www.google.com.br');
});
</script>
它有效,但不是最好的方法,因为每当需要打开多个标签时,它都会显示浏览器阻止弹出窗口的警告。
如果有任何好的建议,我将不胜感激。
提前致谢!
【问题讨论】:
-
好吧,你还是需要打开多个标签页吧?因为如果你有一个标签,你就不能将它重定向到多个 url?
-
@VeselinDavidov 是的,我们需要打开多个标签。抱歉,我没看懂第二个问题。
标签: javascript jsf primefaces