Jump to content

[SOLVED] Submit form open in new window


mfindlay

Recommended Posts

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.

Link to comment
Share on other sites

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;">

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Solved it  8) , 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!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.