Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

issue in javascript

 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an hom.html page where i have username and password fields.. I get those values thru JavaScript.. If these things match with my un and pwd it goes to another page.Else it shows an error message. Here the window.location.href is not working. I tried window.open where it opens a new window by leaving the existing window still exists. I need a page opens within the same window just like response.sendRedirct in JSP..Pls sum one help me to resolve this. Any help would be appreciated...



function callme(form)
{
if(document.forms[0].elements[1].value=="ajax" && document.forms[0].elements[2].value=="ajax")
{
window.location.href = "home.html"
}
else
{
alert("--------");
}
}
 
Rodrigo Lopes
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct is

window.location = "home.html"
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rodrigo Lopes
I have tried that too.. But still that wont seems to be working... What can i do...Anyway thanks for your suggestion...Keep on moving
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off to HTML / JavaScript!
 
Rodrigo Lopes
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried window.location = "home.html"?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rodrigo Lopes:
What happened when you tried window.location = "home.html"?


window.location is not one of the "best practices" of JavaScript. You should use .href as the poster orginally did.


Here the window.location.href is not working.


What is not working? Are you getting an error message? Is the page reloading? Is the world catching on fire? We need some more details and you may want to show us how you are calling your function with a button, link, keyoress etc.

Eric
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could have something like this..



Justin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic