W3 Validation: Does it do scripts?

P

(Pete Cresswell)

I've got a script (slavishly copied from someone kind enough to give it to me)
that works a-ok on the page, but fails W3's validation. Not only that, but it
sets up some kind of open/close problem that makes all the rest of the HTML
fail. Rem out the script, no problems.

Also, I tried pasting the script into a separate, standalone HTML file and
validating it. W3 thought it was and 'application/octet-stream', which W3 does
not support.

The script (in context of the web page):
---------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base target="45thPix_PicArea"/>
<title> Click on a small picture...</title>
<link rel="stylesheet" type="text/css" href="Master.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>

<body>

<script type="text/javascript">
document.write("<p id='ThumbNavListloading'>Loading thumbnails, please
wait...</p>");

function hideloading ()
{
var loading = document.getElementById('ThumbNavListloading');
ThumbNavListloading.style.display = 'none';
}

window.onload = hideloading;
</script>


<div class="ThumbNavListHeader">
<p>To open picture in separate window, hold down Shift key while clicking.</p>
</div>

<div class="ThumbNavlist">

<p><a class="ThumbNavList" href="Pix\45th\100_0102.jpg"><img
src="Pix\45th\ThumbNails\100_0102.jpg" width="120" alt=""/><br/>Al & Pam Miller,
Bill & Susan Donoghue, Hop Evans<br/>(100_0102.jpg)</a></p>
<p><a class="ThumbNavList" href="Pix\45th\100_0103.jpg"><img
src="Pix\45th\ThumbNails\100_0103.jpg" width="120" alt=""/><br/>Hop Evans, Dave
Anderson, Al Miller<br/>(100_0103.jpg)</a></p>
<p><a class="ThumbNavList" href="Pix\45th\100_0104.jpg"><img
src="Pix\45th\ThumbNails\100_0104.jpg" width="120" alt=""/><br/>Al Miller, Pete
Cresswell, Jerry Olin<br/>(100_0104.jpg)</a></p>
<!-- and so-on and so-forth -->

</div>
</body>

</html>
 
B

brucie

In alt.html (Pete Cresswell) said:
I've got a script (slavishly copied from someone kind enough to give it to me)
that works a-ok on the page, but fails W3's validation.

<looks around for url to page and one to the validator output/>
 
E

Eric B. Bednarz

(Pete Cresswell) said:
I've got a script

And you are using document.write to pass HTML tags to the sript engine
and the validator mumbles that the first ETAGO delimiter ('</' followed
by a name start character [a-zA-Z]) terminates the CDATA content of the
SCRIPT element but the generic identifier doesn't match.

Use either document.write('<\/foo>') or document.write('</'+'foo>'), as
you can undoubtedly read in the W3C validator FAQ as well (now how did I
know that without reading the rest of your message and what does that
say about the initialism 'FAQ'?).
 
R

rf

(Pete Cresswell) wrote
I've got a script (slavishly copied from someone kind enough to give it to
me)

<snip>

Hmmm.

You are writing to the XHTML doctype but serving the page up as HTML (so IE
will understand it) I assume.

Well, this causes problems. The browser is attempting to render your script.

You will need to specify that the contents if the script element is, in
fact, cdata. You are not at the moment.

I could give you an answer (actually I can't as I don't write XHTML) but I
think I'll introduce you go google :)

Go to http://groups.google.com and type in xhtml cdata. The first hit
addresses your problem exactly.

BTW why are you writing XHTML. More problems than it's worth IMHO. Every
browser around understands HTML strict.

BTW that page is *ENORMOUS*. If you do eventually get all the thumbnails to
display it will be megabytes big, far too big for the web. I do hope it is a
private page :)
 
E

Eric B. Bednarz

rf said:
You are writing to the XHTML doctype

What's the 'writing to' part all about?
but serving the page up as HTML (so IE
will understand it) I assume.

Well, this causes problems. The browser is attempting to render your script.

You will need to specify that the contents if the script element is, in
fact, cdata. You are not at the moment.

No, he doesn't need to as long as he continues to serve it as tag/soup.
You can then throw with doctype declarations and solidi at will, which
has all kinds of advantages, like stuff and stuff.
 
T

Toby Inkster

Beauregard said:
In windoze, they go this way: \
On the WWW, they go this way: /

Clarification:

On the WWW, they go this way /

On Windows, they go this way \ or this way /

In DOS, they go this way \ or this way /, but some programs force you to
go this way \
 
N

Neredbojias

Without quill or qualm, (Pete Cresswell) quothed:
I've got a script (slavishly copied from someone kind enough to give it to me)
that works a-ok on the page, but fails W3's validation. Not only that, but it
sets up some kind of open/close problem that makes all the rest of the HTML
fail. Rem out the script, no problems.

Also, I tried pasting the script into a separate, standalone HTML file and
validating it. W3 thought it was and 'application/octet-stream', which W3 does
not support.

The problem is you have to make special provisions when using script with
xhtml. It's best to check references yourself, but here's the ebginning
and end, which may be all you need:

<script type="text/javascript">
//<![CDATA[


//]]>
</script>

-nerb
 
M

Michael Winter

[snip]

[Modified for wrap]
<script type="text/javascript">
document.write("<p id='ThumbNavListloading'>Loading thumbnails,"
+ " please wait...</p>");

You've already been told that said:
function hideloading ()
{
var loading = document.getElementById('ThumbNavListloading');

You should feature-test the the browser actually supports gEBI unless
you're writing for a restricted audience that you *know* will support it.
Similarly with the style object below.
ThumbNavListloading.style.display = 'none';

You look up a reference, then completely ignore it. Interesting.

You might want to know that the majority of browsers will fail on that
line. You cannot reference an element using its id (or its name). That's
nonsense that Microsoft dreamed up.
}

window.onload = hideloading;

You could also avoid creating a named function seeing as it's only going
to be called one time.

/* Check that document.getElementById is supported. */
if(document.getElementById) {
/* Create an anonymous function. */
window.onload = function() {
var ld = document.getElementById('ThumbNavListloading');
/* Check that the element was found. */
if(ld) {
/* If the style object is supported, modify its display
* property. If not, create it on the element itself.
*/
(ld.style || ld).display = 'none';
}
};
}

The issues I've briefly mentioned are covered in the c.l.js FAQ
(<URL:http://jibbering.com/faq/>).

[snip]

Mike
 
P

(Pete Cresswell)

richard said:
BTW that page is *ENORMOUS*. If you do eventually get all the thumbnails to
display it will be megabytes big, far too big for the web. I do hope it is a
private page :)

Not even a private page. It's just something that will be published on a CD.
No performance problems there....

Actually, believe-it-or-not, it is usable as a web page over a dialup
connection. Not blazingly fast....in fact I might get high blood pressure if I
had to peruse it at length...but amazingly it actually is usable....not that
that's it's intended use.
 
N

Neal

On the WWW, they go this way /

On Windows, they go this way \ or this way /

In DOS, they go this way \ or this way /, but some programs force you to
go this way \

"While some people prefer to go both ways!" - Scarecrow
 

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

Similar Threads

Help with Visual Lightbox: Scripts 2
Help with code 0
JQuery hover error 3
Help with my responsive home page 2
<div> help 1
Please Help? 0
Controlling size of the image that href= opens? 47
Aligned to the left 3

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top