简体   繁体   English

如何使用JavaScript打开新窗口?

[英]How to open new window using JavaScript?

I have a requirement to open a new window(URL is dynamic) when I click on a button. 当我点击按钮时,我需要打开一个新窗口(URL是动态的)。

function openWindow(){
     window.open('//www.google.com/','_blank');
}

Here my problem is , JavaScript is opening new window but Appliation name is also appending to URL. 我的问题是,JavaScript正在打开新窗口,但Appliation名称也附加到URL。 ie it is opening new window with the below URL 即它用以下URL打开新窗口

http://localhost:8090/www.google.com/ HTTP://本地主机:8090 / www.google.com /

I have tried all the combinations in URL but it is not working 我已尝试过URL中的所有组合,但它无效

Please do needful 请做好

update your javascript function like 更新你的javascript函数就好

function openWindow(){
     window.open('http://www.google.com/','_blank');
}

Use action listener to open new window in icefaces 使用动作侦听器在icefaces中打开新窗口

<ice:commandLink value="click me" actionListener="#{bean.myActionListener}"/> 
------------------------------

public void myActionListener(ActionEvent event) { 
    JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(), "window.open('report.iface', 'myWindow');"); 
} 
------------------------------

Use window.open("http://www.google.com"); 使用window.open("http://www.google.com"); , tested works in all browsers. ,测试适用于所有浏览器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM