Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > W3C html validator flags error in javascript

Reply
Thread Tools

W3C html validator flags error in javascript

 
 
xyZed
Guest
Posts: n/a
 
      03-25-2006
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/valida...ms.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
 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      03-25-2006
xyZed wrote:

> 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/valida...ms.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
end tags are allowed within a <script> element. This has _nothing_ to do
with flagging JavaScript errors or processing JavaScript in any way.

> 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
 
Reply With Quote
 
 
 
 
Toby Inkster
Guest
Posts: n/a
 
      03-25-2006
xyZed wrote:

> 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/valida...ms.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.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
xyZed
Guest
Posts: n/a
 
      03-27-2006
There is circumstantial evidence that on Sat, 25 Mar 2006 16:06:58
+0200, "Jukka K. Korpela" <(E-Mail Removed)> wrote
__________________________________________________ _____


> > 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
 
Reply With Quote
 
xyZed
Guest
Posts: n/a
 
      03-27-2006
There is circumstantial evidence that on Sat, 25 Mar 2006 14:54:02
+0000, Toby Inkster <(E-Mail Removed)> wrote
__________________________________________________ _____


> 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/valida...ms.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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Quetion about flags of socket.recv(bufsize, [flags]) Steve Holden Python 0 02-08-2009 04:09 PM
W3c Validator usage & can't see error David Cox Javascript 2 08-13-2007 11:09 AM
W3C Validator error: Tag Name not present =?Utf-8?B?Qm9i?= ASP .Net 3 06-15-2006 02:53 AM
W3C Validator Icon and W3C Valdiator page Frank HTML 9 05-03-2004 09:32 AM
Newbie : Charset with W3C HTML validator Paul Blay HTML 6 12-09-2003 08:22 PM



Advertisments