1

I have a requirement to open a new window(URL is dynamic) when I click on a button.

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. i.e it is opening new window with the below URL

http://localhost:8090/www.google.com/

I have tried all the combinations in URL but it is not working

Please do needful

6
  • Try adding the protocol for the URL. That JavaScript works fine in both Firefox and Chrome for me though. Commented Feb 9, 2016 at 7:32
  • the code you showed should open http://www.google.com - which will probably redirect to https - but it works fine in firefox anyway Commented Feb 9, 2016 at 7:33
  • @jaromanda this code is opening new window , but as below localhost:8090/www.google.com .. I want to remove localhost:8090 Commented Feb 9, 2016 at 7:39
  • your code does NOT do that at least in firefox, chrome, ie or edge - but the solution below should work Commented Feb 9, 2016 at 7:40
  • 1
    here's proof that the general concept of what you are doing works ... perhaps icefaces / jsf is screwing up your code somehow - what does the code look like when you view it in the browser (view page source) Commented Feb 9, 2016 at 7:44

3 Answers 3

4

update your javascript function like

function openWindow(){
     window.open('http://www.google.com/','_blank');
}
Sign up to request clarification or add additional context in comments.

1 Comment

@Raj create a online demo which you try to implement
0

Use action listener to open new window in icefaces

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

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

2 Comments

hi developerbhuwan, I tried this code before writing java script. it is also not working , thats the reason I moved to java script .
and I tried below code also.. it is not working too JavaScriptRunner.runScript(FacesContext.getCurrentInstance(), "window.open('google.com' , '_newtab');");
0

Use window.open("http://www.google.com");, tested works in all browsers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.