I have javascript as follows function newDoc() { window.location.href ="http://192.168.0.8/devit/logon.html"; } Code (markup): If I call this function from my javascript as follows newDoc(); Code (markup): it fails but if called from HTML <input type="button" nanme="SelectButton" id="SelectButton" value="Login" onclick="newDoc()" height="50"/> Code (markup): it works. Please tell me what I am getting wrong.
I have several questions to be able to answer your question: What is the context of where you are calling this from when it doesn't work? What error message are you getting when it doesn't work? Have you tried running it with a debugger to follow the code through to where it gets the error? I recommend Chrome with the Javascript Console. It lets you see what is going on.