is it possilble that a <form> dont open a new window

W

Wouter

Hi,

I try to make when i send a <form> that he dont open a new window. Is there
someone who know how i can make this whit javascript ?

Greets Wouter
 
Y

Yann-Erwan Perio

Wouter wrote:

Hi,
I try to make when i send a <form> that he dont open a new window. Is there
someone who know how i can make this whit javascript ?

Generally a form does not open a new window when submitted, if it does
then you either have a "target" attribute in your form opening tag or a
"target" property defined in scripting - just remove it and the form
will be submitted in the current window, as you wish.


HTH,
Yep.
 
D

David Dorward

Wouter said:
I try to make when i send a <form> that he dont open a new window.

The default behavior of forms is to submit to the same window.
Is there someone who know how i can make this whit javascript ?

You don't need JavaScript to make the default happen. You have to take
explicit steps to change the behavior from the default.
 
W

Wouter

Generally a form does not open a new window when submitted, if it does
then you either have a "target" attribute in your form opening tag or a
"target" property defined in scripting - just remove it and the form will
be submitted in the current window, as you wish.

Sorry i forgot to say i need a target because the form is using for login a
forum

Greets Wouter
 
D

David Dorward

Wouter said:
Sorry i forgot to say i need a target because the form is using for login
a forum

Why? The sole purpose of the target attribute is to determine which
window/frame the document will load in. It has no effect on what data is
sent to the server, so it can't be required because it is being used for a
login form.
 
Y

Yann-Erwan Perio

Sorry i forgot to say i need a target because the form is using for login a
forum

If you mean that you have a popup window as entry point to your forum,
and want that the loaded form be in the main window, then try adding a
target="_top" in the login form, in the popup.

Otherwise could you post some code exemplifying your issue?


Thanks,
Yep.
 
W

Wouter

Otherwise could you post some code exemplifying your issue?
I'm dont use a popup.

<FORM action="http://test.mydomain.com/forum/login.php" method="post"
target="main">
<INPUT class="post" size="12" name="username" value="Username">
<INPUT class="post" type="password" size="12" name="password"
value="Password">
<input type="hidden" name="redirect" value="redirect.php?url=<?php echo
$url; ?>">
<INPUT class="text" type="checkbox" name="autologin"></td>
<input class="mainoption" type="submit" value="Inloggen"
name="login">

Greets WOuter
 
Y

Yann-Erwan Perio

Wouter said:
<FORM action="http://test.mydomain.com/forum/login.php" method="post"
target="main">
<input type="hidden" name="redirect" value="redirect.php?url=<?php echo
$url; ?>">


I'm sorry I still cannot get the pattern you're using. Do you have
frames, as one could understand from "target=main"? What is the role of
the hidden control?

What happens if you remove target="main"? If you remove the input
type="hidden"?


Thanks,
Yep.
 
W

Wouter

I'm sorry I still cannot get the pattern you're using. Do you have frames,
as one could understand from "target=main"? What is the role of the hidden
control?

The target main is needed by the forum. otherwise he dont cant login.
What happens if you remove target="main"? If you remove the input
type="hidden"?

The hidden field does a redirect to page where the user login. otherwise he
will see the index of the forum

Greets Wouter
 
C

cosmic foo

Wouter said:
Hi,

I try to make when i send a <form> that he dont open a new window. Is there
someone who know how i can make this whit javascript ?

Greets Wouter


lol!
 
W

Wouter

I dont know ecactely why because its a phpbb forum and the code are
sometimes deficalt to read. But when i delete the target main i cant login
anymore.

Greets Wouter
 
Y

Yann-Erwan Perio

I dont know ecactely why because its a phpbb forum and the code are
sometimes deficalt to read. But when i delete the target main i cant login
anymore.

We're not getting anywhere here, do you have an online URL demonstrating
the problem? Without reproducing the steps and undertanding the issue
it's hard to give you correct advice.

Currently, what we have is:
- you have a popup that is opened in result of the form submission,
while you would like to not have any popup,
- this behavior is probably due to the target attribute of the FORM,
which points to something called "main" - since you don't have any frame
called "main" it opens a popup,
- if there's no target the login does not work - what happens here, what
do you mean by "can't login anymore"? Do you have any error message?


Thanks,
Yep.
 
W

Wouter

We're not getting anywhere here, do you have an online URL demonstrating
the problem? Without reproducing the steps and undertanding the issue it's
hard to give you correct advice.

Currently, what we have is:
- you have a popup that is opened in result of the form submission, while
you would like to not have any popup,
- this behavior is probably due to the target attribute of the FORM, which
points to something called "main" - since you don't have any frame called
"main" it opens a popup,
- if there's no target the login does not work - what happens here, what
do you mean by "can't login anymore"? Do you have any error message?

Yes you can see it online.

check: http://webshop.addrenaline.com/content/algemeen/algemeen/0/
if you want to login you can use as pass and login: usenet

Greets Wouter
 
Y

Yann-Erwan Perio

Wouter said:
check: http://webshop.addrenaline.com/content/algemeen/algemeen/0/
if you want to login you can use as pass and login: usenet

Thanks this is clearer now.

The approach in your page is dependent on javascript, which means that
if your user does not have javascript activated, it will fail. Moreover,
it's dependent on popups, which may be blocked by popup blockers.
Therefore, if you have the chance, I suggest you drop the popup thing
and include the login/password fields directly in the main page.

Now, if you want to keep this popup approach, then update the main file
and the popup file with the following patterns.


--- main file ---
<script type="text/javascript">
self.name="main";
</script>

<a href="login.html"
target="popup"
onclick="loginPopup=window.open(this.href, this.target)">Login</a>
---


--- popup file ---
<form action="doLogin.html"
target="main"
onsubmit="setTimeout(function(){window.close()},1);return true">
<input type="submit">
</form>
 
W

Wouter

Yann-Erwan Perio said:
Thanks this is clearer now.

The approach in your page is dependent on javascript, which means that if
your user does not have javascript activated, it will fail. Moreover, it's
dependent on popups, which may be blocked by popup blockers. Therefore, if
you have the chance, I suggest you drop the popup thing and include the
login/password fields directly in the main page.

Thats a good point i dont think about that! But when i include the
login/pass fields in de main site then i have a other problem that i need to
close the window where the user enter his login/pass....
I think i most go to learn mutvh better javascript! :) I think i will try to
make this but the javascript is again a problem i think because i dont know
how i close a window behind...
Now, if you want to keep this popup approach, then update the main file
and the popup file with the following patterns.
Thx for the code! But i will first to try to get everything on the main page
:)
HTH,
Yep.

Greets Wouter
 
W

Wouter

Thx for the code! But i will first to try to get everything on the main
page :)

I have make fast a login on the main page and it works fine only when i
close the window i get a messages i i'm sure i want to close the window. So
thats why i want to know i it polibele whit javascript to send a form whit a
target in the same window.

Greets Wouter
 
Y

Yann-Erwan Perio

Wouter said:
I have make fast a login on the main page and it works fine only when i
close the window i get a messages i i'm sure i want to close the window.

This is a security feature, you can only close a window that you have
opened, not the main window.
So
thats why i want to know i it polibele whit javascript to send a form whit a
target in the same window.

If everything is on the main window, then you don't need any target
anymore, just remove the window.name stuff and the target (or define it
to "_self") and this should work.

When working with specific issues it's always better to write a
dedicated test case, since you don't have to keep in view details
irrelevant to your test - if you have a hard time having it work, then
simplify your test case until you really just have the points you want
to validate.


HTH,
Yep.
 
Y

Yann-Erwan Perio

Yann-Erwan Perio said:
If everything is on the main window, then you don't need any target
anymore, just remove the window.name stuff and the target (or define it
to "_self") and this should work.

And of course remove the self.close() call, since you're working with
one window you don't want to close it.


Cheers,
Yep.
 
W

Wouter

If everything is on the main window, then you don't need any target
anymore, just remove the window.name stuff and the target (or define it to
"_self") and this should work.

It look like that everything is on the main window. But the send the data to
/forum/login.php and after login he redirect to /forum/redirect.php and that
file checks from where the user wants to login and redirect him then to the
place where the user clicks login.

But the target needs PHPbb so i cant delete the target.

Greets Wouter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top