W3C html validator flags error in javascript

X

xyZed

Although related to false javascript errors during validation checks,
this is a question about html validation.

I have several affiliate links stopping my pages validating. They use
javascript which I don't understand. Apparently it's a known issue
that html validators can erroneously flag javascript errors.

I have read the information on this page

http://www.htmlhelp.com/tools/validator/problems.html#script

which offers a solution. But I do not want to accidently disable the
javascript functions of my affiliate links by adding stuff I don't
understand.

The W3C (and dreamweaver's) validators flag the following error -

< found between tags. Consider using the equivalent entity (&amp =
'&', &lt = '<', &gt = '>', &quot = quotation mark). [HTML 4.0]

And this is the script it flags up -

<script type="text/javascript">
var uri = 'http://impgb.tradedoubler.com/imp/js/16125532/1079419?' +
new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript language="javaScript" src="'+uri+'"
charset="ISO-8859-1"></sc'+'ript>');
</script>


I can fix this by adding a back slash here <\/sc'+'ript>' as mentioned
on
http://www.htmlhelp.com/tools/validator/problems.html#script

<quoting relevant passage>

"A common error (and the most common source of erroneous bug reports
for the WDG HTML Validator) occurs when writing HTML tags within a
SCRIPT element:

<script type="text/javascript">
<!--
// This is an error!
document.write("</P>");
// -->
</script>

(The fix is to add a backslash -)

<script type="text/javascript">
<!--
document.write("<\/P>");
// -->
</script>
</quote>


I'm hoping someone can tell me if this is a legitimate fix and that it
won't interfere with the javascript functions please












--

Free washing machine help and advice.

www.washerhelp.co.uk

www.xyzed.co.uk/newsgroups/top-posting.html
 
J

Jukka K. Korpela

xyZed said:
Although related to false javascript errors during validation checks,
this is a question about html validation.

It's about validation of HTML documents, but it's not about "false
javascript errors", just about common failures to understand what
validation is.
I have several affiliate links stopping my pages validating. They use
javascript which I don't understand.

Too bad. Your choice: get rid of them or learn to understand what this
is about, then perhaps fix them.
Apparently it's a known issue
that html validators can erroneously flag javascript errors.

It's not true at all.
I have read the information on this page
http://www.htmlhelp.com/tools/validator/problems.html#script

which offers a solution.

Indeed. Another solution is to put JavaScript code into an external
file. Yet another, often feasible and perhaps the best, is to remove the
JavaScript code or to replace it by something more robust (like
replacing a fake "JavaScript link" by a real link).
The W3C (and dreamweaver's) validators flag the following error -

< found between tags. Consider using the equivalent entity (&amp =
'&', &lt = '<', &gt = '>', &quot = quotation mark). [HTML 4.0]

What are you referring to? Please specify the source of your quotations.
And this is the script it flags up -

<script type="text/javascript">
var uri = 'http://impgb.tradedoubler.com/imp/js/16125532/1079419?' +
new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript language="javaScript" src="'+uri+'"
charset="ISO-8859-1"></sc'+'ript>');
</script>

The _error_ here, assuming HTML 4 rules, is the presence of "</sc",
which starts an end tag. There is no such tag in HTML 4 and, besides, no
I can fix this by adding a back slash here <\/sc'+'ript>' as mentioned
on
http://www.htmlhelp.com/tools/validator/problems.html#script

Yes, or by using an external file. Or by other means, but these two are
the simplest, probably.
I'm hoping someone can tell me if this is a legitimate fix and that it
won't interfere with the javascript functions please

Huh? Do you expect the general level of expertise in this group to
exceed that of the people beging the www.htmlhelp.com site? Rest assured
it doesn't. But you can also check the _official_ (though sloppily
written) HTML 4 specification and see that the same method is suggested
there, though this has been hidden into an appendix:
http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2
 
T

Toby Inkster

xyZed said:
I have several affiliate links stopping my pages validating. They use
javascript which I don't understand. Apparently it's a known issue
that html validators can erroneously flag javascript errors.

Firstly, the validator is not erroneous -- it is acting correctly -- your
HTML is invalid.

Secondly, there is no Javascript error. The Javascript is fine in itself;
it has simply been embedded into the HTML wrongly.
I have read the information on this page
http://www.htmlhelp.com/tools/validator/problems.html#script
which offers a solution. But I do not want to accidently disable the
javascript functions of my affiliate links by adding stuff I don't
understand.

The solution proposed on that page is fine. It won't change how your
Javascript operates.
 
X

xyZed

There is circumstantial evidence that on Sat, 25 Mar 2006 16:06:58
_______________________________________________________

› > I have several affiliate links stopping my pages validating. They use
› > javascript which I don't understand.

› Too bad. Your choice: get rid of them or learn to understand what this
› is about, then perhaps fix them.

Exactly why I posted. This is my first step.
› > Apparently it's a known issue
› > that html validators can erroneously flag javascript errors.

› It's not true at all.

They flag phantom html errors, not (as I said) javascript errors,
and of course it's not the fault of the html validators.

› ... Another solution is to put JavaScript code into an external
› file.

That may be a good idea, would it have advantages other than the one
discussed here I wonder? I'd have to look into how it would work for
affiliate links and banners that are different on each page though.
› ..Yet another, often feasible and perhaps the best, is to remove the
› JavaScript code or to replace it by something more robust (like
› replacing a fake "JavaScript link" by a real link).

I have yet to learn about doing such things. I hate having to use
other people's rubbish code. It seems to me that the overwhelming
majority of affiliate link code is poorly coded javascript. You are
right that I should learn what code is being put on my site but I am
so busy running and updating my site I have not had time. I do need
the affiliate links though so it's something I've seen as a necessary
evil.

Thanks for the links


--

Free washing machine help and advice.

www.washerhelp.co.uk

www.xyzed.co.uk/newsgroups/top-posting.html
 
X

xyZed

There is circumstantial evidence that on Sat, 25 Mar 2006 14:54:02
_______________________________________________________

› Firstly, the validator is not erroneous -- it is acting correctly -- your
› HTML is invalid.
› Secondly, there is no Javascript error. The Javascript is fine in itself;
› it has simply been embedded into the HTML wrongly.

The validator is flagging erroneous errors, but only because the
poorly written javascript code fools the html validator into thinking
the code is html (or something like that) I think I mistakenly said
they were flagging javascript errors but the correct observation
should be they are flagging html errors in javascript code?

› > I have read the information on this page
› > http://www.htmlhelp.com/tools/validator/problems.html#script
› > which offers a solution. But I do not want to accidently disable the
› > javascript functions of my affiliate links by adding stuff I don't
› > understand.

› The solution proposed on that page is fine. It won't change how your
› Javascript operates.

Thank you.

--

Free washing machine help and advice.

www.washerhelp.co.uk

www.xyzed.co.uk/newsgroups/top-posting.html
 

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,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top