The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> form results in new window (strictly speaking)
jimlongo
post Oct 2 2006, 12:20 PM
Post #1


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



I use this code to put a Google search on some pages
HTML
<form method=GET action="http://www.google.com/search" target="_blank">
<div><input type=hidden name=ie value=iso-8859-1></div>
<div><input type=hidden name=oe value=iso-8859-1></div>
<table><tr><td>
<a href="http://www.google.com/">
<img src="http://www.google.com/logos/Logo_40wht.gif" alt="Google"></a>
</td>
<td>
<input type=text name=q size=31 maxlength=255 value="">
<input type=submit name=btnG VALUE="Google Search">
<input type=hidden name=domains value="domain.com"><br> <input type=radio name=sitesearch value="domain.com" checked> domain.com<img src="images/spacer.gif" height="1" width="15" alt=""> <input type=radio name=sitesearch value=""> www<br>
</td></tr></table>
</form>


I want to remove the target="_blank" from there but still have it open in another window.


this is the javascript I normally use to open a link in a new window . . .
CODE
<a href="http://www.someplace.com"  onclick="java script:openWin('http://www.someplace.com'); return false">


Is there a way to combine this to make the search results open in a new window when I'm using a angry.gif STRICT DOCTYPE?mad.gif

Thanks,
jim
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 2 2006, 01:47 PM
Post #2


.
********

Group: WDG Moderators
Posts: 8,206
Joined: 10-August 06
Member No.: 7



Since one of the points of HTML Strict is to disallow the TARGET attribute, why try to circumvent it?

If you still want to do it, you might "cheat" by inserting a TARGET attribute in the FORM element with javascript (that way the validator will not notice).

Or you might open a javascript popup window with an URL consisting of the FORM's ACTION attribute and a query string put together by the form fields' name/value pairs.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Oct 2 2006, 02:08 PM
Post #3


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



QUOTE(Christian J @ Oct 2 2006, 02:47 PM) *

Since one of the points of HTML Strict is to disallow the TARGET attribute, why try to circumvent it?

I didn't take the fact that this attribute was deprecated to mean that the practice of opening a new window was somehow verboten.

As a user, I prefer that whenever a link is going to take me to another site that a new window be opened. I guess opinions may differ in this area. But as a designer I definitely don't want a link to ever close the window with my site in it.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 2 2006, 02:37 PM
Post #4


.
********

Group: WDG Moderators
Posts: 8,206
Joined: 10-August 06
Member No.: 7



QUOTE(jimlongo @ Oct 2 2006, 09:08 PM) *

I didn't take the fact that this attribute was deprecated to mean that the practice of opening a new window was somehow verboten.


I don't think it's deprecated in Transitional, but it's indeed verboten in Strict.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Oct 2 2006, 02:53 PM
Post #5


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



I got that TARGET is a no-no, so that's why i'm trying to inject some javascript in the form. But I can't seem to get it to work, I've tried onclick in the submit section
CODE

<input type=submit name=btnG VALUE="Google Search" onclick="java script:openWin('http://www.google.com/search'); return false">


and onsubmit
CODE

<input type=submit name=btnG VALUE="Google Search" onsubmit="java script:openWin('http://www.google.com/search'); return false">


and I've tried it in the action line in place of target="_blank" as well but none of those options do anything.


I'm afraid i'm not too fluent in javascript or forms, and my friend Google is leading me nowhere so i could use a little fish or literal direction here. wacko.gif

Thanks,
jim
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Oct 2 2006, 02:57 PM
Post #6


WDG Member
********

Group: Root Admin
Posts: 8,308
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE(jimlongo @ Oct 2 2006, 12:08 PM) *
As a user, I prefer that whenever a link is going to take me to another site that a new window be opened. I guess opinions may differ in this area.
As a web user, I sometimes want to open links in the same window, and sometimes want to open links in new windows. I find it easiest when the web author leaves the decision up to me, so I can click or Shift-click or Ctrl-Shift-click as desired.

QUOTE(jimlongo @ Oct 2 2006, 12:08 PM) *
But as a designer I definitely don't want a link to ever close the window with my site in it.
That's good. The windowing system provides multiple standard ways to close windows. The user should be familiar with at least one of them.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Oct 2 2006, 03:03 PM
Post #7


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



QUOTE(Darin McGrew @ Oct 2 2006, 03:57 PM) *

QUOTE(jimlongo @ Oct 2 2006, 12:08 PM) *
As a user, I prefer that whenever a link is going to take me to another site that a new window be opened. I guess opinions may differ in this area.
As a web user, I sometimes want to open links in the same window, and sometimes want to open links in new windows. I find it easiest when the web author leaves the decision up to me, so I can click or Shift-click or Ctrl-Shift-click as desired.


Yes but you are a "smart user", a "joe user" wouldn't be aware until it's too late that he's left the building. smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 2 2006, 03:51 PM
Post #8


.
********

Group: WDG Moderators
Posts: 8,206
Joined: 10-August 06
Member No.: 7



QUOTE(jimlongo @ Oct 2 2006, 09:53 PM) *

I got that TARGET is a no-no, so that's why i'm trying to inject some javascript in the form. But I can't seem to get it to work, I've tried onclick in the submit section
CODE

<input type=submit name=btnG VALUE="Google Search" onclick="java script:openWin('http://www.google.com/search'); return false">


and onsubmit
CODE

<input type=submit name=btnG VALUE="Google Search" onsubmit="java script:openWin('http://www.google.com/search'); return false">



You need the query string with the search terms after the URL. I tried to find out how to get that from the form page onsubmit, but couldn't find anything, so I guess you'll have to let the script add the form field name/value pairs one by one before submitting.

QUOTE

and I've tried it in the action line in place of target="_blank" as well but none of those options do anything.


This appears to work:

CODE
<form action="..." onsubmit="this.target='_blank';">
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 2 2006, 05:38 PM
Post #9


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,352
Joined: 9-August 06
Member No.: 6



Where did my post go? I swear - I saw it. IPB Image

Oh well. Mine was basically the same as what Christan posted. Gives you some variation. tongue.gif
CODE
onsubmit="this.setAttribute('target','_blank');"
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Oct 2 2006, 05:41 PM
Post #10


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



Thank you both.

After all that i've decided to let this search return in the same window blush.gif
- since afterall the next click should return them to the site being searched - but it's good to know anyway. biggrin.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 2 2006, 06:08 PM
Post #11


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,352
Joined: 9-August 06
Member No.: 6



Lord, give me strength. IPB Image

IPB Image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Oct 2 2006, 06:40 PM
Post #12


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



QUOTE(pandy @ Oct 2 2006, 07:08 PM) *

Lord, give me strength. IPB Image

Don't worry, I've been procrastinating about getting down to work on a project . . . you may not have me to kick around for a while. unsure.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Oct 3 2006, 08:35 AM
Post #13


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



QUOTE(Christian J @ Oct 3 2006, 03:47 AM) *

Since one of the points of HTML Strict is to disallow the TARGET attribute, why try to circumvent it?


Can you give any rational basis for this urge to "disallow the TARGET attribute"?

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 3 2006, 12:59 PM
Post #14


.
********

Group: WDG Moderators
Posts: 8,206
Joined: 10-August 06
Member No.: 7



QUOTE(Brian Chandler @ Oct 3 2006, 03:35 PM) *

QUOTE(Christian J @ Oct 3 2006, 03:47 AM) *

Since one of the points of HTML Strict is to disallow the TARGET attribute, why try to circumvent it?


Can you give any rational basis for this urge to "disallow the TARGET attribute"?


Apparently W3C eventually decided not to like (i)frames either, and without frames frame targets became unnecessary. Regarding new windows I guess W3C wants the users to decide.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 21st August 2019 - 05:52 PM