• Post Reply Bookmark Topic Watch Topic
  • New Topic

window.location problem  RSS feed

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple form in which if I click one button, I am supposed to go to other web page. I have used javascript function to this. I could do this with a normal html button where my page is not redirected if I use jsf command button. Why such discrepency? window.open is working where as window.location.href is nto working. Please let me know.
 
Anil Sadineni
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you post the code on what you trying to do?

Anil.
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<script type="text/javascript">
function function2() {
window.location.href = "http://www.mozilla.org";


}
</script>


<f:view>
<html>

<body>
<form id="myForm">
<h:panelGrid>
<h:commandButton value="checkStatus"
onclick
="function2()" />
</h:panelGrid>

</form>

</body>
</html>
</f:view>
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This function works perfectly fine when I tried testing like below:


Why it is not working when i use onclick as below:


Anything wrong in using onclick from a JSF commandButton?
 
venkata swamymora
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

You can use


or

[code]
window.location='yourPage.faces';
[code]

try this one.It will solve your problem

venkat
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Venkat. I tried both, they are not working for me.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Script should be declared within the HEAD tag within the HTML tag

[code]
<html>
<head>
<script type="text/javascript">
function function2() {
window.location.href = "http://www.mozilla.org";


}
</script>
</head>
<body>
....
</body>
</html>
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, I have placed my javascript function within html head tag. STill wondering why it is nto working.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!