converting to STRICT (href values and target attribute)

P

petermichaux

Hi,

I am converting an old page to STRICT.

When validating the page I learned that I can't have a link like the
following. The '&' and '=' characters are not allowed? How can I make
this link validate?

<a
href="http://www.foo.com/cgi-bin/test.pl?ACCOUNT=1006458&THE_BUTTON=display_page&PAGE_TYPE=MI_PPC#ASDF">


I also learned that I can't use the "target" attribute in STRICT pages
like the following. What do I do to get around this? Do I have to write
JavaScript in the onclick attribute? That wouldn't be so good if
JavaScript is off.

<a href="http://www.7Search.com/" target="new">7Search.com</a>

Thank you,
Peter
 
D

dorayme

Hi,

I am converting an old page to STRICT.

When validating the page I learned that I can't have a link like the
following. The '&' and '=' characters are not allowed? How can I make
this link validate?

<a
href="http://www.foo.com/cgi-bin/test.pl?ACCOUNT=1006458&THE_BUTTON=display_pa
ge&PAGE_TYPE=MI_PPC#ASDF">

Best to post the url for this as email and ng postings can pay
tricks on url presentations
I also learned that I can't use the "target" attribute in STRICT pages
like the following. What do I do to get around this? Do I have to write
JavaScript in the onclick attribute? That wouldn't be so good if
JavaScript is off.

<a href="http://www.7Search.com/" target="new">7Search.com</a>

Not heard of "new" as a value here? Don't use strict if you need
target. You using frames?
 
P

petermichaux

dorayme said:
Best to post the url for this as email and ng postings can pay
tricks on url presentations

I'm not sure what you mean. The URL has a '?' followed by parameters
like this

ACCOUNT=1006458&THE_BUTTON=display_page

http://www.foo.com/cgi-bin/test.pl?ACCOUNT=1006458&THE_BUTTON=display_page&PAGE_TYPE=MI_PPC#ASDF

The ampersands and equals signs are apparently not allowed with the
strict doctype.

Not heard of "new" as a value here? Don't use strict if you need
target. You using frames?

I'm not using frames. The target is for a new window that may already
be open. For example, if I have the following in a page then the first
click opens a new window. More clicks change that same new window.

<p><a href="http://www.google.com" target="foo">google.com</a></p>
<p><a href="http://www.yahoo.com" target="foo">yahoo.com</a></p>

How to convert this kind of behavior to strict doctype?

Thanks,
Peter
 
D

dorayme

I'm not sure what you mean.

Just that you should try to put up your efforts on a server so we
can see what you are doing, you give us an address of where to
look.
I'm not using frames. The target is for a new window that may already
be open. For example, if I have the following in a page then the first
click opens a new window. More clicks change that same new window.

<p><a href="http://www.google.com" target="foo">google.com</a></p>
<p><a href="http://www.yahoo.com" target="foo">yahoo.com</a></p>

How to convert this kind of behavior to strict doctype?

Where did you get the idea to use the word "new"? I may be
missing something.

If you want a link to open in a new window, you can use the
construction <a href="destination.html" target="_blank">

You can use this in docs with

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

They will not validate. This is not the end of the world. You can
still do it. Many browsers will not blink and it will work as you
want.

Your other choice is to use a transitional doc type.

The other thing you can do, and this is generally the best thing
to do: review your wanting to control the windows of website
user. Now that there is tabbed browsing and greater familiarity
with browsers, it is often best to simply leave all this stuff to
the user. This is another reason a URL is desirable. So your
business can be seen completely and we can poke our noses in and
say what is what and how things should or should not be. :)
 
R

richard

Hi,

I am converting an old page to STRICT.

When validating the page I learned that I can't have a link like the
following. The '&' and '=' characters are not allowed? How can I make
this link validate?

<a
href="http://www.foo.com/cgi-bin/test.pl?ACCOUNT=1006458&THE_BUTTON=display_page&PAGE_TYPE=MI_PPC#ASDF">


I also learned that I can't use the "target" attribute in STRICT pages
like the following. What do I do to get around this? Do I have to write
JavaScript in the onclick attribute? That wouldn't be so good if
JavaScript is off.

<a href="http://www.7Search.com/" target="new">7Search.com</a>

Thank you,
Peter

The validator generally gives you some reasons why the error occurred. Read
up on them.

In general, &amp is best used instead of just &.
"new" should be _blank.
You should take the time to learn what attributes go with which terms.
learn the basics of coding.
 
J

Joel Shepherd

Hi,

I am converting an old page to STRICT.

When validating the page I learned that I can't have a link like the
following. The '&' and '=' characters are not allowed? How can I make
this link validate?

<a
href="http://www.foo.com/cgi-bin/test.pl?ACCOUNT=1006458&THE_BUTTON=display_pa
ge&PAGE_TYPE=MI_PPC#ASDF">

http://www.example.com/cgi-bin/test.pl?ACCOUNT=1006458&amp;THE_BUTTON=dis
play_page&amp;PAGE_TYPE=MI_PPC#ASDF

.... Should make the validator happier.

Why? Suppose your URL looked like this instead:

http://www.example.com/cgi-bin/test.pl?ACCOUNT=1006458&COPY=2&PAGE_TYPE=M
I_PPC#ASDF

&copy is a defined character entity in HTML. The href value in a link is
CDATA, and browsers are supposed to interpret CDATA:

"CDATA is a sequence of characters from the document character set and
may include character entities. User agents should interpret attribute
values as follows:
* Replace character entities with characters,
* Ignore line feeds,
* Replace each carriage return or tab with a single space."

(http://www.w3.org/TR/html401/types.html#type-cdata)

So your browser would be strongly tempted to replace the &COPY in the
above URL with a copyright symbol character ... and that's probably not
what you want.

Use &amp; instead of & in URLs to separate parameters: browsers will
handle it properly and you'll avoid risk of unintended interpretation.
I also learned that I can't use the "target" attribute in STRICT pages
like the following. What do I do to get around this? Do I have to write
JavaScript in the onclick attribute?
Yes.

That wouldn't be so good if JavaScript is off.

True, but if the user turned it off, he/she probably knows how to open
pages in new windows/tabs/whatever anyways. If the user isn't human, it
doesn't care.
 
U

usenet+2004

richard:
In general, &amp is best used instead of just &.

although if a Name character follows, the entity reference must be
closed explicitly, with a semi-colon.
"new" should be _blank.

They mean different things. With 'new', user-agents SHOULD either load
the resource in a new frame named 'new' or if a frame named 'new'
already exists, load the resource in that frame. The spec talks about
known and unknown frames here. With '_blank', they SHOULD load the
resource in a 'new, unnamed window', regardless of existing frames.
All that assumes that the user-agent understands 'target', that it
doesn't override the attribute, and that there are such things as
frames and windows.
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top