submit target new

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

submit target new

Post by m2babaey »

Hi
when we click a button ( input of submit type) we are redirected to the action page in the same window by default
What code is used and where should we use that code to open the action page in a new window?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Set the "target" attribute to "_blank" of your form and this should open the results in a new window. I beleive this is non-compliant.. so beware
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Jcart wrote:I beleive this is non-compliant.. so beware
It's non-compliant with XHTML1.1 strict, but 1.0 transitional allows it.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

There's always the JavaScript way! :teach:
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

JellyFish wrote:There's always the JavaScript way! :teach:
JOKING: Also, there is always a pop-up blocker :)

Almost every pop-up blocker blocks pop-ups when there are no user's click (or some other required user's action). But *almost* ... some blockers wouldn't be so kind ;)

While using target _blank I have had no problems.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Pop ups adds are such a bad idea. Who here thinks that they should have never been used for that purpose?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

JellyFish wrote:There's always the JavaScript way! :teach:
Your JS suggestion?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

window.open :wink:
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

It is still a pop-up, right ? ;)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

huh? window.open will open a new window, yes.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

...

I mean:

Code: Select all

var E;

try
{
     window.open( ............. );
}
catch (E)
{
     alert("You have a popup blocker!");
}
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Any behavior that emulates a user's action can potentially be blocked. It all really depends on the browser/client your and how they define a popup.
Post Reply