mfindlay Posted April 18, 2007 Share Posted April 18, 2007 Hi, Compltete JavaScript novice here, I wonder if you could help? I am trying to re-use some code which opens a new window from a lik and adapt it to work in a form, the function is as follows <script type="text/javascript"> <!--Hide script from old browsers function newWindow(newContent) { winContent = window.open(newContent, 'nextWin', 'toolbar=0 ,scrollbars=1, resizable=1') } //Stop hiding script from old browsers --> </script> and I can call it succesfully by using <a href="javascript:newWindow('link.html')">View link</a> But what I really want to do is login to an application and have that open in a new window, so I've changed the app login page to login from my site which works and I end up logged in to the app. So I would like thid to happen in a new window, so I've used the code below <form name="login" method="post" action="javascript:newWindow('https://app.dll')"> and what happens is the new window appears as expected but instead of being logged into the app I am sent to the login page of the app, any ideas?? Cheers, Mark. Quote Link to comment Share on other sites More sharing options...
mainewoods Posted April 19, 2007 Share Posted April 19, 2007 use the target="_blank" in the form tag: <form name="login" action="https://app.dll" method="post" target="_blank"> if you are using a strict doctype that won't validate. i believe you can use: <form name="login" action="https://app.dll" method="post" onsubmit="this.target='_blank';return true;"> Quote Link to comment Share on other sites More sharing options...
mfindlay Posted April 19, 2007 Author Share Posted April 19, 2007 Thanks, sorry I should have explained myself better, the problem isn't opening the app in a new window 'target' will do just nicely for that (is a shame about the validation though! onSubmit isn't liked either!). I want to be able to disable the browser buttons too - hence the need for JavaScript. This is an online exam system, and we have had problems with students using browser navigation which screws up the session. So I have re-written the app login page to a login page on our site, so the students login on our site and the get their exam in a new window with no browser buttons. If I don't use the JavaScript above and use 'target' then I can login to an exam and my details are passed through and I can veiw any exams available. If I do use the JavaScript above then I login using the form I have created and the login screen of the sytstem then appears in a new window with no browser buttons - so it seems as though my details are not passing through. does this make more sense? Quote Link to comment Share on other sites More sharing options...
mfindlay Posted April 19, 2007 Author Share Posted April 19, 2007 Solved it , this does the trick..... <script language="JavaScript"> function doSubmit() {displayWindow = window.open('', "newWin","scrollbars=1,menubar=0,toolbar=0,resizable=1,location=0,status=0"); document.submitForm.submit();} </script> <form name="login" action="https://app.dll" method="post" target="newWin"> <input type="submit" name="Enter" title="Enter" value="Enter" onclick="doSubmit()" /> Happy Bunny!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.