By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

HTML works but javascript fails with href

P: 6
I have javascript as follows
Expand|Select|Wrap|Line Numbers
  1. function newDoc()
  2.     {
  3.     window.location.href = "http://192.168.0.8/devit/logon.html";
  4.     }
  5.  
If I call this function from my javascript as follows
Expand|Select|Wrap|Line Numbers
  1.         newDoc();
  2.  
it fails but if called from HTML
Expand|Select|Wrap|Line Numbers
  1. <input type="button" nanme="SelectButton" id="SelectButton" value="Login" onclick="newDoc()" height="50" />
  2.  
it works.
Please tell me what I am getting wrong.
Jul 5 '13 #1

✓ answered by gits

what does FF or Chrome's javascript-console report as error? that will give you a hint already. otherwise we would need to see more of the code - may be you call the function before its declared or similar.

Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,268
what does FF or Chrome's javascript-console report as error? that will give you a hint already. otherwise we would need to see more of the code - may be you call the function before its declared or similar.
Jul 5 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.