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

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

P: n/a
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
Jul 24 '05 #1
Share this Question
Share on Google+
19 Replies


P: n/a
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.
Jul 24 '05 #2

P: n/a
Wouter wrote:
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.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 24 '05 #3

P: n/a
>
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
Jul 24 '05 #4

P: n/a
Wouter wrote:
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


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.

Jul 24 '05 #5

P: n/a
Wouter wrote:
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.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 24 '05 #6

P: n/a
> 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
Jul 24 '05 #7

P: n/a
Wouter wrote:
<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.
Jul 24 '05 #8

P: n/a
> 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
Jul 24 '05 #9

P: n/a
Wouter wrote:
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.


Why not?

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 24 '05 #10

P: n/a

"Wouter" <laptop@_NOSPAM.com> wrote in message
news:42***********************@news.wanadoo.nl...
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!
Jul 24 '05 #11

P: n/a
>>
The target main is needed by the forum. otherwise he dont cant login.


Why not?

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
Jul 24 '05 #12

P: n/a
Wouter wrote:
The target main is needed by the forum. otherwise he dont cant login.
Why not?

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.
Jul 24 '05 #13

P: n/a
> 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/conte...en/algemeen/0/
if you want to login you can use as pass and login: usenet

Greets Wouter
Jul 24 '05 #14

P: n/a
Wouter wrote:
check: http://webshop.addrenaline.com/conte...en/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>
---
HTH,
Yep.
Jul 24 '05 #15

P: n/a

"Yann-Erwan Perio" <ye*@invalid.com> schreef in bericht
news:42***********************@news.free.fr...
Wouter wrote:
check: http://webshop.addrenaline.com/conte...en/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.


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
Jul 24 '05 #16

P: n/a
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 :)


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
Jul 24 '05 #17

P: n/a
Wouter wrote:
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.
Jul 24 '05 #18

P: n/a
Yann-Erwan Perio wrote:
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.
Jul 24 '05 #19

P: n/a
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
Jul 24 '05 #20

This discussion thread is closed

Replies have been disabled for this discussion.